Add ArrayVec::dispose()
This commit is contained in:
+7
-3
@@ -57,9 +57,7 @@ pub struct ArrayVec<A: Array> {
|
||||
|
||||
impl<A: Array> Drop for ArrayVec<A> {
|
||||
fn drop(&mut self) {
|
||||
// clear all elements
|
||||
while let Some(_) = self.pop() {
|
||||
}
|
||||
self.clear();
|
||||
|
||||
// NoDrop inhibits array's drop
|
||||
// panic safety: NoDrop::drop will trigger on panic, so the inner
|
||||
@@ -340,6 +338,12 @@ impl<A: Array> ArrayVec<A> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Dispose of `self` without the overwriting that is needed in Drop.
|
||||
pub fn dispose(mut self) {
|
||||
self.clear();
|
||||
mem::forget(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Array> Deref for ArrayVec<A> {
|
||||
|
||||
Reference in New Issue
Block a user