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

Method get

publication/code/chapter10/conshash.rs:87–95  ·  view source on GitHub ↗

获取结点

(&self, key: u64)

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.45

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected