Skip to content

Commit e6948e7

Browse files
authored
Add a provided TryClone::clone_panic_on_oom method (bytecodealliance#12675)
1 parent 25e3bd1 commit e6948e7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/core/src/alloc/try_clone.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ pub trait TryClone: Sized {
88
/// Attempt to clone `self`, returning an error if any allocation fails
99
/// during cloning.
1010
fn try_clone(&self) -> Result<Self, OutOfMemory>;
11+
12+
/// Clone `self`, panicking on allocation failure.
13+
fn clone_panic_on_oom(&self) -> Self {
14+
use super::PanicOnOom as _;
15+
self.try_clone().panic_on_oom()
16+
}
1117
}
1218

1319
impl<T> TryClone for *mut T

0 commit comments

Comments
 (0)