File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 38
38
//!
39
39
//! This crate is guaranteed to compile on latest stable Rust. It *might* compile on older
40
40
//! versions but that may change in any new patch release.
41
+ //!
42
+ //! # Examples
43
+ //!
44
+ //! ```
45
+ //! use hash32::{FnvHasher, Hasher as _};
46
+ //!
47
+ //! #[derive(Hash)]
48
+ //! struct Person {
49
+ //! id: u32,
50
+ //! name: &'static str,
51
+ //! phone: u64,
52
+ //! }
53
+ //!
54
+ //! let person1 = Person {
55
+ //! id: 5,
56
+ //! name: "Janet",
57
+ //! phone: 555_666_7777,
58
+ //! };
59
+ //! let person2 = Person {
60
+ //! id: 5,
61
+ //! name: "Bob",
62
+ //! phone: 555_666_7777,
63
+ //! };
64
+ //!
65
+ //! assert!(calculate_hash(&person1) != calculate_hash(&person2));
66
+ //!
67
+ //! fn calculate_hash<T: core::hash::Hash>(t: &T) -> u32 {
68
+ //! let mut fnv: FnvHasher = Default::default();
69
+ //! t.hash(&mut fnv);
70
+ //! fnv.finish32()
71
+ //! }
72
+ //! ```
41
73
42
74
#![ warn(
43
75
missing_docs,
You can’t perform that action at this time.
0 commit comments