Skip to content

Commit cba077f

Browse files
committed
add drop()
1 parent 906e550 commit cba077f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/flatbuffers/unsafe_tools.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ where
118118
}
119119
}
120120

121+
impl<T, const MAX_SIZE: usize> Drop for StackVector<T, MAX_SIZE> {
122+
fn drop(&mut self) {
123+
for i in 0..self.size {
124+
unsafe { self.data[i].assume_init_drop() };
125+
}
126+
}
127+
}
128+
121129
impl<T, const MAX_SIZE: usize> StackVector<T, MAX_SIZE> {
122130
pub fn push(&mut self, value: T) -> bool {
123131
if self.size < MAX_SIZE {
@@ -134,6 +142,9 @@ impl<T, const MAX_SIZE: usize> StackVector<T, MAX_SIZE> {
134142
}
135143

136144
pub fn clear(&mut self) {
145+
for i in 0..self.size {
146+
unsafe { self.data[i].assume_init_drop() };
147+
}
137148
self.size = 0;
138149
}
139150

0 commit comments

Comments
 (0)