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

Function hash

publication/code/chapter10/conshash.rs:27–31  ·  view source on GitHub ↗

哈希计算函数

(val: &T)

Source from the content-addressed store, hash-verified

25
26// 哈希计算函数
27fn hash<T: Hash>(val: &T) -> u64 {
28 let mut hasher = DefaultHasher::new();
29 val.hash(&mut hasher);
30 hasher.finish()
31}
32
33// 环
34struct 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