diff --git a/src/collections/raw_vec.rs b/src/collections/raw_vec.rs index 89ca6c2ac19bfc99e5ec1dad7609213e0dd2df70..0abf43a06ac1d39f500751c698e40150ded015b4 100644 --- a/src/collections/raw_vec.rs +++ b/src/collections/raw_vec.rs @@ -34,7 +34,7 @@ impl RawVec { pub fn with_capacity(capacity: usize) -> Self { // Could be done a bit more efficiently let mut result = Self::new(); - result.ensure_space(capacity); + result.ensure_space(capacity).unwrap(); return result; } @@ -49,7 +49,7 @@ impl RawVec { } pub fn push(&mut self, item: T) { - self.ensure_space(1); + self.ensure_space(1).unwrap(); unsafe { let target = self.base.add(self.len); std::ptr::write(target, item); @@ -87,7 +87,7 @@ impl RawVec { dealloc(old_base, old_layout); } - self.base = new_base; + self.base = new_base as *mut T; self.cap = new_cap; } } // else: still enough space @@ -114,7 +114,7 @@ impl Drop for RawVec { debug_assert!(!self.base.is_null()); let (_, layout) = self.current_layout(); unsafe { - dealloc(self.base, layout); + dealloc(self.base as *mut u8, layout); if cfg!(debug_assertions) { self.base = ptr::null_mut(); }