MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / hash

Function hash

code/chapter09/conshash.rs:26–30  ·  view source on GitHub ↗

哈希计算函数

(val: &T)

Source from the content-addressed store, hash-verified

24
25// 哈希计算函数
26fn hash<T: Hash>(val: &T) -> u64 {
27 let mut hasher = DefaultHasher::new();
28 val.hash(&mut hasher);
29 hasher.finish()
30}
31
32// 环
33struct Ring<T: Clone + ToString + Debug> {

Callers 3

addMethod · 0.70
removeMethod · 0.70
mainFunction · 0.70

Calls 1

hashMethod · 0.45

Tested by

no test coverage detected