pub unsafe trait AllocDst<T: ?Sized + Dst>: Sized + Borrow<T> {
// Required method
unsafe fn try_new_dst<F, E>(
len: usize,
layout: Layout,
init: F,
) -> Result<Self, E>
where F: FnOnce(NonNull<T>) -> Result<(), E>;
// Provided method
unsafe fn new_dst<F>(len: usize, layout: Layout, init: F) -> Self
where F: FnOnce(NonNull<T>) { ... }
}Expand description
Required Methods§
Sourceunsafe fn try_new_dst<F, E>(
len: usize,
layout: Layout,
init: F,
) -> Result<Self, E>
unsafe fn try_new_dst<F, E>( len: usize, layout: Layout, init: F, ) -> Result<Self, E>
Allocate the DST with the given length, initialize the data with the given fallible function, and store it in the type.
§Safety
The layout must accurately describe an object of type T with length len.
The init function must correctly initialize the data pointed to, or return an
error.
§Errors
This function will only return an error in the case that the init function
returns an error.
Provided Methods§
Sourceunsafe fn new_dst<F>(len: usize, layout: Layout, init: F) -> Self
unsafe fn new_dst<F>(len: usize, layout: Layout, init: F) -> Self
Allocate the DST with the given length, initialize the data with the given function, and store it in the type.
§Safety
The layout must accurately describe an object of type T with length len.
The init function must correctly initialize the data pointed to.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".