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

Method get_raw_mut

cranelift/entity/src/primary.rs:234–243  ·  view source on GitHub ↗

Analog of `get_raw` except that a raw pointer is returned rather than a mutable reference. The default accessors of items in [`PrimaryMap`] will invalidate all previous borrows obtained from the map according to miri. This function can be used to acquire a pointer and then subsequently acquire a second pointer later on without invalidating the first one. In other words this is only here to help b

(&mut self, k: K)

Source from the content-addressed store, hash-verified

232 /// pointer later on without invalidating the first one. In other words
233 /// this is only here to help borrow two elements simultaneously with miri.
234 pub fn get_raw_mut(&mut self, k: K) -> Option<*mut V> {
235 if k.index() < self.elems.len() {
236 // SAFETY: the `add` function requires that the index is in-bounds
237 // with respect to the allocation which is satisfied here due to
238 // the bounds-check above.
239 unsafe { Some(self.elems.as_mut_ptr().add(k.index())) }
240 } else {
241 None
242 }
243 }
244}
245
246impl<K, V> Default for PrimaryMap<K, V>

Callers

nothing calls this directly

Calls 4

indexMethod · 0.45
lenMethod · 0.45
addMethod · 0.45
as_mut_ptrMethod · 0.45

Tested by

no test coverage detected