Fix recycling on component callbacks (#2247)

This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-04-04 16:48:06 -07:00
1 parent 0a3291084f
commit 702509cb7e
2 files changed
+10 -5

No files matched your search

+9 -4
View File
@@ -198,12 +198,17 @@ impl<T, S: Storage<T>> GenerationalBox<T, S> {
}
}
/// Drop the value out of the generational box and invalidate the generational box. This will return the value if the value was taken.
/// Recycle the generationalbox, dropping the value.
pub fn recycle(&self) {
_ = Storage::take(&self.raw.0.data);
<S as AnyStorage>::recycle(&self.raw);
}
/// Drop the value out of the generational box and invalidate the generational box.
/// This will return the value if the value was taken.
pub fn manually_drop(&self) -> Option<T> {
if self.validate() {
let o = Storage::take(&self.raw.0.data);
<S as AnyStorage>::recycle(&self.raw);
o
Storage::take(&self.raw.0.data)
} else {
None
}