pub trait Initialize: Sized {
// Required method
fn initialize() -> Self;
// Provided method
unsafe fn initialize_raw(data: *mut ()) { ... }
}Expand description
Writes a default value through a raw pointer.
Type-erased containers cannot call Default::default, so they call
Initialize::initialize_raw through a function pointer. Implemented for
every Default type.
Required Methods§
Sourcefn initialize() -> Self
fn initialize() -> Self
Returns the initial value of this type.
Provided Methods§
Sourceunsafe fn initialize_raw(data: *mut ())
unsafe fn initialize_raw(data: *mut ())
Writes the initial value into already allocated memory.
§Safety
data must be non-null, writable and aligned for Self, and must not
hold an initialized value already (the old value is overwritten without
being dropped).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".