Skip to content

Commit 4b8c866

Browse files
committed
Provide no-std example of IsEnabled custom impl usage, bar std-reliant test behind feature check
1 parent a84940c commit 4b8c866

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ impl<T> Copy for NoHashHasher<T> {}
203203
/// # Example
204204
///
205205
/// ```
206+
/// use std::hash::{BuildHasher, Hasher, Hash};
207+
/// use fp_nohash_hasher::NoHashHasher;
208+
///
206209
/// #[derive(PartialEq, Eq)]
207210
/// struct SomeType(u32);
208211
///
@@ -213,14 +216,21 @@ impl<T> Copy for NoHashHasher<T> {}
213216
/// }
214217
///
215218
/// impl fp_nohash_hasher::IsEnabled for SomeType {}
216-
///
219+
///#[cfg(feature = "std")] {
217220
/// let mut m = fp_nohash_hasher::IntMap::default();
218221
///
219222
/// m.insert(SomeType(1), 't');
220223
/// m.insert(SomeType(0), 'f');
221224
///
222225
/// assert_eq!(Some(&'t'), m.get(&SomeType(1)));
223226
/// assert_eq!(Some(&'f'), m.get(&SomeType(0)));
227+
/// }
228+
///
229+
/// let mut hasher: NoHashHasher<SomeType> = fp_nohash_hasher::BuildNoHashHasher::default().build_hasher();
230+
///
231+
/// SomeType(12345).hash(&mut hasher);
232+
///
233+
/// assert_eq!(12345u64, hasher.finish());
224234
/// ```
225235
pub trait IsEnabled {}
226236

0 commit comments

Comments
 (0)