update take

This commit is contained in:
Conrad Ludgate
2021-05-26 20:08:02 +01:00
parent 8778483b12
commit 6dc46b3a1c
+2 -11
View File
@@ -646,17 +646,8 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
array
}
pub fn take(&mut self) -> Option<[T; CAP]> {
if self.len() < self.capacity() {
None
} else {
unsafe { Some(self.take_unchecked()) }
}
}
pub unsafe fn take_unchecked(&mut self) -> [T; CAP] {
let data = std::mem::replace(self, Self::new());
data.into_inner_unchecked()
pub fn take(&mut self) -> Self {
mem::replace(self, Self::new())
}
/// Return a slice containing all elements of the vector.