Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 2 additions & 28 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ pub use seeded_state::{FxHashMapSeed, FxHashSetSeed};
/// The current implementation is a fast polynomial hash with a single
/// bit rotation as a finishing step designed by Orson Peters.
#[derive(Clone)]
#[cfg_attr(not(feature = "nightly"), derive(Default))]
#[cfg_attr(feature = "nightly", derive_const(Default))]
pub struct FxHasher {
hash: usize,
}
Expand Down Expand Up @@ -90,34 +92,6 @@ impl FxHasher {
}
}

#[cfg(not(feature = "nightly"))]
macro_rules! default_impl {
() => {
impl Default for FxHasher {
#[inline]
fn default() -> FxHasher {
Self::default()
}
}
};
}

// In order to use the nightly-only `const` syntax, we gate the definition behind a macro so that
// parsing still succeeds on stable.
#[cfg(feature = "nightly")]
macro_rules! default_impl {
() => {
impl const Default for FxHasher {
#[inline]
fn default() -> FxHasher {
Self::default()
}
}
};
}

default_impl!();

impl FxHasher {
#[inline]
fn add_to_hash(&mut self, i: usize) {
Expand Down
2 changes: 1 addition & 1 deletion src/random_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ mod tests {
// `1 / 2.pow(bit_size_of::<usize>())`. Or 1/1.7e19 for 64 bit platforms or 1/4294967295
// for 32 bit platforms. I suppose this is acceptable.
let a = FxHashMapRand::<&str, u32>::default();
let b = thread::spawn(|| FxHashMapRand::<&str, u32>::default())
let b = thread::spawn(FxHashMapRand::<&str, u32>::default)
.join()
.unwrap();

Expand Down
Loading