Skip to content

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

Add a provided `TryClone::clone_panic_on_oom` method (#12675)

Nick Fitzgeralde6948e754292
diff --git a/crates/core/src/alloc/try_clone.rs b/crates/core/src/alloc/try_clone.rs
index 85837f94c7..ca426fb0b7 100644
--- a/crates/core/src/alloc/try_clone.rs
+++ b/crates/core/src/alloc/try_clone.rs
@@ -8,6 +8,12 @@ pub trait TryClone: Sized {
/// Attempt to clone `self`, returning an error if any allocation fails
/// during cloning.
fn try_clone(&self) -> Result<Self, OutOfMemory>;
+
+ /// Clone `self`, panicking on allocation failure.
+ fn clone_panic_on_oom(&self) -> Self {
+ use super::PanicOnOom as _;
+ self.try_clone().panic_on_oom()
+ }
}
impl<T> TryClone for *mut T