Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
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
// 哈希计算函数
27
fn hash<T: Hash>(val: &T) -> u64 {
28
let mut hasher = DefaultHasher::new();
29
val.hash(&mut hasher);
30
hasher.finish()
31
}
32
33
// 环
34
struct Ring<T: Clone + ToString + Debug> {
Callers
3
add
Method · 0.70
remove
Method · 0.70
main
Function · 0.70
Calls
1
hash
Method · 0.45
Tested by
no test coverage detected