A trait for values that can be cloned, but contain owned, heap-allocated values whose allocations may fail during cloning.
| 5 | /// A trait for values that can be cloned, but contain owned, heap-allocated |
| 6 | /// values whose allocations may fail during cloning. |
| 7 | pub trait TryClone: Sized { |
| 8 | /// Attempt to clone `self`, returning an error if any allocation fails |
| 9 | /// during cloning. |
| 10 | 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 | } |
| 17 | } |
| 18 | |
| 19 | impl<T> TryClone for *mut T |
| 20 | where |
no outgoing calls
no test coverage detected