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

Method get_mut

rust/src/get_operations.rs:138–144  ·  view source on GitHub ↗

Get a mutable reference to the value for a key. # Arguments `key` - The key to look up # Returns A mutable reference to the value if the key exists, `None` otherwise. # Examples ``` use bplustree::BPlusTreeMap; let mut tree = BPlusTreeMap::new(16).unwrap(); tree.insert(1, "one"); if let Some(value) = tree.get_mut(&1) { value = "ONE"; } assert_eq!(tree.get(&1), Some(&"ONE")); ```

(&mut self, key: &K)

Source from the content-addressed store, hash-verified

136 /// assert_eq!(tree.get(&1), Some(&"ONE"));
137 /// ```
138 pub fn get_mut(&mut self, key: &K) -> Option<&mut V> {
139 let (leaf_id, index, matched) = self.find_leaf_for_key_with_match(key)?;
140 if !matched {
141 return None;
142 }
143 self.get_leaf_mut(leaf_id)?.get_value_mut(index)
144 }
145
146 /// Try to get a value, returning detailed error context on failure.
147 ///

Callers 4

get_leaf_mutMethod · 0.45
get_branch_mutMethod · 0.45
test_get_mutFunction · 0.45

Calls 3

get_value_mutMethod · 0.80
get_leaf_mutMethod · 0.80

Tested by 2

test_get_mutFunction · 0.36