slice_dst

Trait TryAllocSliceDst

Source
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§

Source

unsafe fn try_new_slice_dst<I, E>(len: usize, init: I) -> Result<Self, E>
where I: FnOnce(NonNull<S>) -> Result<(), 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.

Implementations on Foreign Types§

Source§

impl<S: ?Sized + SliceDst> TryAllocSliceDst<S> for Box<S>

Source§

unsafe fn try_new_slice_dst<I, E>(len: usize, init: I) -> Result<Self, E>
where I: FnOnce(NonNull<S>) -> Result<(), E>,

Source§

impl<S: ?Sized + SliceDst> TryAllocSliceDst<S> for Rc<S>

Source§

unsafe fn try_new_slice_dst<I, E>(len: usize, init: I) -> Result<Self, E>
where I: FnOnce(NonNull<S>) -> Result<(), E>,

Source§

impl<S: ?Sized + SliceDst> TryAllocSliceDst<S> for Arc<S>

Source§

unsafe fn try_new_slice_dst<I, E>(len: usize, init: I) -> Result<Self, E>
where I: FnOnce(NonNull<S>) -> Result<(), E>,

Implementors§