MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / get_mut

Method get_mut

cranelift/entity/src/sparse.rs:114–123  ·  view source on GitHub ↗

Returns a mutable reference to the value corresponding to the key. Note that the returned value must not be mutated in a way that would change its key. This would invalidate the sparse set data structure.

(&mut self, key: K)

Source from the content-addressed store, hash-verified

112 /// Note that the returned value must not be mutated in a way that would change its key. This
113 /// would invalidate the sparse set data structure.
114 pub fn get_mut(&mut self, key: K) -> Option<&mut V> {
115 if let Some(idx) = self.sparse.get(key).cloned() {
116 if let Some(entry) = self.dense.get_mut(idx as usize) {
117 if entry.key() == key {
118 return Some(entry);
119 }
120 }
121 }
122 None
123 }
124
125 /// Return the index into `dense` of the value corresponding to `key`.
126 fn index(&self, key: K) -> Option<usize> {

Callers 1

insertMethod · 0.45

Calls 2

getMethod · 0.45
keyMethod · 0.45

Tested by

no test coverage detected