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