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 5757//!
5858//! This crate is guaranteed to compile on latest stable Rust. It *might* compile on older
5959//! versions but that may change in any new patch release.
60+ //!
61+ //! # Examples
62+ //!
63+ //! ```
64+ //! use hash32::{FnvHasher, Hasher as _};
65+ //!
66+ //! #[derive(Hash)]
67+ //! struct Person {
68+ //! id: u32,
69+ //! name: &'static str,
70+ //! phone: u64,
71+ //! }
72+ //!
73+ //! let person1 = Person {
74+ //! id: 5,
75+ //! name: "Janet",
76+ //! phone: 555_666_7777,
77+ //! };
78+ //! let person2 = Person {
79+ //! id: 5,
80+ //! name: "Bob",
81+ //! phone: 555_666_7777,
82+ //! };
83+ //!
84+ //! assert!(calculate_hash(&person1) != calculate_hash(&person2));
85+ //!
86+ //! fn calculate_hash<T: core::hash::Hash>(t: &T) -> u32 {
87+ //! let mut fnv: FnvHasher = Default::default();
88+ //! t.hash(&mut fnv);
89+ //! fnv.finish32()
90+ //! }
91+ //! ```
6092
6193#![ warn(
6294 missing_docs,
You can’t perform that action at this time.
0 commit comments