Skip to content

Commit 852b817

Browse files
committed
Replace mem::replace with ptr::read
1 parent b87afd3 commit 852b817

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,16 +821,16 @@ impl<A: Array> SmallVec<A> {
821821
}
822822
}
823823

824-
pub fn into_inner(mut self) -> Result<A, Self> {
825824
/// Convert the SmallVec into an `A` if possible. Otherwise return `Err(Self)`.
826825
///
827826
/// This method returns `Err(Self)` if the SmallVec is too short (and the `A` contains uninitialized elements),
828827
/// or if the SmallVec is too long (and all the elements were spilled to the heap).
828+
pub fn into_inner(self) -> Result<A, Self> {
829829
if self.spilled() || self.len() != A::size() {
830830
Err(self)
831831
} else {
832832
unsafe {
833-
let data = mem::replace(&mut self.data, SmallVecData::from_inline(mem::uninitialized()));
833+
let data = ptr::read(&self.data);
834834
mem::forget(self);
835835
Ok(data.into_inline())
836836
}

0 commit comments

Comments
 (0)