Skip to content

Commit

Permalink
Fix doc.rs build (#75)
Browse files Browse the repository at this point in the history
* Fix docs.rs build

* Fix docs.rs build

* Use rustversion to add compatibility with older rustc versions
  • Loading branch information
ogxd authored May 27, 2024
1 parent 5a23285 commit 9bca158
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "gxhash"
authors = ["Olivier Giniaux"]
version = "3.3.0"
version = "3.3.1"
edition = "2021"
description = "GxHash non-cryptographic algorithm"
license = "MIT"
Expand All @@ -22,7 +22,7 @@ bench-plot = []
hybrid = []

[dependencies]
# No dependencies!
rustversion = "1.0" # Compile-time cfg based on rustc version for compatibility

[dev-dependencies]
rand = "0.8"
Expand Down
6 changes: 4 additions & 2 deletions src/gxhash/platform/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#[cfg(all(any(target_arch = "arm", target_arch = "aarch64"), target_feature = "aes", target_feature = "neon"))]
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
#[cfg(all(target_feature = "aes", target_feature = "neon"))]
#[path = "arm.rs"]
mod platform;

#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", target_feature = "sse2"))]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(any(all(target_feature = "aes", target_feature = "sse2"), docsrs))] // docsrs bypasses the target_feature check
#[path = "x86.rs"]
mod platform;

Expand Down
9 changes: 8 additions & 1 deletion src/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,17 @@ impl Hasher for GxHasher {
#[derive(Clone, Debug)]
pub struct GxBuildHasher(State);

#[rustversion::before(1.76)]
use std::collections::hash_map::RandomState;

#[rustversion::since(1.76)]
use std::hash::RandomState;

impl Default for GxBuildHasher {
#[inline]
fn default() -> GxBuildHasher {
let random_state = std::hash::RandomState::new();

let random_state = RandomState::new();
unsafe {
let state: State = std::mem::transmute(random_state);
GxBuildHasher(state)
Expand Down

0 comments on commit 9bca158

Please sign in to comment.