Skip to content

Commit 6dc46b3

Browse files
committed
update take
1 parent 8778483 commit 6dc46b3

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/arrayvec.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -646,17 +646,8 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
646646
array
647647
}
648648

649-
pub fn take(&mut self) -> Option<[T; CAP]> {
650-
if self.len() < self.capacity() {
651-
None
652-
} else {
653-
unsafe { Some(self.take_unchecked()) }
654-
}
655-
}
656-
657-
pub unsafe fn take_unchecked(&mut self) -> [T; CAP] {
658-
let data = std::mem::replace(self, Self::new());
659-
data.into_inner_unchecked()
649+
pub fn take(&mut self) -> Self {
650+
mem::replace(self, Self::new())
660651
}
661652

662653
/// Return a slice containing all elements of the vector.

0 commit comments

Comments
 (0)