MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / try_get

Method try_get

rust/src/get_operations.rs:166–168  ·  view source on GitHub ↗

Try to get a value, returning detailed error context on failure. # Arguments `key` - The key to look up # Returns A reference to the value if the key exists, or a detailed error. # Examples ``` use bplustree::BPlusTreeMap; let mut tree = BPlusTreeMap::new(16).unwrap(); tree.insert(1, "one"); assert!(tree.try_get(&1).is_ok()); assert!(tree.try_get(&2).is_err()); ```

(&self, key: &K)

Source from the content-addressed store, hash-verified

164 /// assert!(tree.try_get(&2).is_err());
165 /// ```
166 pub fn try_get(&self, key: &K) -> KeyResult<&V> {
167 self.get(key).ok_or(BPlusTreeError::KeyNotFound)
168 }
169
170 /// Get multiple keys with detailed error reporting.
171 ///

Callers 2

test_try_getFunction · 0.80

Calls 1

getMethod · 0.45

Tested by 2

test_try_getFunction · 0.64