pub trait InitDefault: Sized {
// Required method
fn init_default() -> impl Init<Self>;
}Expand description
A trait for types that have a canonical, stack-safe, in-place default initializer.
This is the in-place initialization analogue of Default: unlike Default::default()
which returns Self by value (potentially materializing a large value on the stack),
init_default() returns an Init<Self> that writes the value directly into its
final memory location. This is essential for large types (e.g. buffers sized in MiB)
whose on-stack construction would overflow the stack.
Required Methods§
Sourcefn init_default() -> impl Init<Self>
fn init_default() -> impl Init<Self>
Returns a canonical in-place initializer for Self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".