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

Method get

publication/code/chapter08/rbtree.rs:272–285  ·  view source on GitHub ↗

获取值引用及可变引用

(&self, key: &K)

Source from the content-addressed store, hash-verified

270
271 // 获取值引用及可变引用
272 fn get(&self, key: &K) -> Option<&V> {
273 unsafe {
274 let mut node = self.root;
275 while !node.is_null() {
276 node = match (*node).key.cmp(key) {
277 Less => (*node).right,
278 Equal => return Some(&(*node).val),
279 Greater => (*node).left,
280 }
281 }
282 }
283
284 None
285 }
286
287 fn get_mut(&self, key: &K) -> Option<&mut V> {
288 unsafe {

Callers

nothing calls this directly

Calls 1

cmpMethod · 0.45

Tested by

no test coverage detected