1use std::ops::{Deref, DerefMut};
2
3pub struct TailDropVec<T> {
4 vec: Vec<T>,
5}
6
7impl<T> Drop for TailDropVec<T> {
8 fn drop(&mut self) {
9 loop {
10 if let None = self.vec.pop() {
11 break;
12 }
13 }
14 }
15}
16
17impl<T> From<Vec<T>> for TailDropVec<T> {
18 fn from(vec: Vec<T>) -> Self {
19 TailDropVec { vec }
20 }
21}
22
23impl<T> Deref for TailDropVec<T> {
24 type Target = Vec<T>;
25
26 fn deref(&self) -> &Self::Target {
27 &self.vec
28 }
29}
30
31impl<T> DerefMut for TailDropVec<T> {
32 fn deref_mut(&mut self) -> &mut Self::Target {
33 &mut self.vec
34 }
35}