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)
| 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> { |