diff --git a/src/indexmap.rs b/src/indexmap.rs index dc60a3b52a..c61d131c2d 100644 --- a/src/indexmap.rs +++ b/src/indexmap.rs @@ -416,7 +416,8 @@ where unsafe { // SAFETY: Already checked existence at instantiation and the only mutable reference // to the map is internally held. - Ok(&mut self.core.entries.get_unchecked_mut(inserted.index).value) + Ok(&mut (*self.core.entries.as_mut_ptr().add(inserted.index)).value) + //Ok(&mut self.core.entries.get_unchecked_mut(inserted.index).value) } } Insert::Full((_, v)) => Err(v), diff --git a/src/vec.rs b/src/vec.rs index bef2edd0a8..a77afac5b8 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -107,6 +107,16 @@ impl Vec { new } + /// Returns a raw pointer to the vector’s buffer. + pub fn as_ptr(&self) -> *const T { + self.buffer.as_ptr() as *const T + } + + /// Returns a raw pointer to the vector’s buffer, which may be mutated through. + pub fn as_mut_ptr(&mut self) -> *mut T { + self.buffer.as_mut_ptr() as *mut T + } + /// Extracts a slice containing the entire vector. /// /// Equivalent to `&s[..]`.