pub unsafe trait TryAllocSliceDst<S: ?Sized + SliceDst>: AllocSliceDst<S> + Sized {
// Required method
unsafe fn try_new_slice_dst<I, E>(len: usize, init: I) -> Result<Self, E>
where I: FnOnce(NonNull<S>) -> Result<(), E>;
}
Expand description
Types that can allocate a custom slice DST within them, given a fallible initialization function.
Required Methods§
Sourceunsafe fn try_new_slice_dst<I, E>(len: usize, init: I) -> Result<Self, E>
unsafe fn try_new_slice_dst<I, E>(len: usize, init: I) -> Result<Self, E>
Create a new custom slice DST with a fallible initialization function.
§Safety
init
must properly initialize the object behind the pointer.
init
receives a fully uninitialized pointer and must not read anything before writing.
If the initialization closure panics or returns an error, the allocated place will be deallocated but not dropped. To clean up the partially initialized type, we suggest proxying creation through scope guarding types.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.