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

Method get

code/chapter09/conshash.rs:84–92  ·  view source on GitHub ↗

查询结点

(&self, key: u64)

Source from the content-addressed store, hash-verified

82
83 // 查询结点
84 fn get(&self, key: u64) -> Option<&T> {
85 if self.ring.is_empty() {
86 return None;
87 }
88 let mut keys = self.ring.keys();
89 keys.find(|&k| k >= &key)
90 .and_then(|k| self.ring.get(k))
91 .or(keys.nth(0).and_then(|x| self.ring.get(x)))
92 }
93}
94
95fn main() {

Callers 1

mainFunction · 0.45

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected