Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Add a `clear` method to our OOM-handling `Vec` (#12620)

Nick Fitzgerald763ace02000f
diff --git a/crates/core/src/alloc/vec.rs b/crates/core/src/alloc/vec.rs
index 681371f03c..c1cd3d3360 100644
--- a/crates/core/src/alloc/vec.rs
+++ b/crates/core/src/alloc/vec.rs
@@ -288,6 +288,11 @@ impl<T> Vec<T> {
// use `std`'s `into_boxed_slice` without fear of `realloc`.
Ok(self.inner.into_boxed_slice())
}
+
+ /// Same as [`std::vec::Vec::clear`].
+ pub fn clear(&mut self) {
+ self.inner.clear();
+ }
}
impl<T> Deref for Vec<T> {