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> {
|
impl<A: Array> Drop for ArrayVec<A> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// clear all elements
|
self.clear();
|
||||||
while let Some(_) = self.pop() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// NoDrop inhibits array's drop
|
// NoDrop inhibits array's drop
|
||||||
// panic safety: NoDrop::drop will trigger on panic, so the inner
|
// 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> {
|
impl<A: Array> Deref for ArrayVec<A> {
|
||||||
|
|||||||
Reference in New Issue
Block a user