Macro kernel::init

source ·
macro_rules! init {
    ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
        $($fields:tt)*
    }) => { ... };
}
Expand description

Construct an in-place initializer for structs.

This macro defaults the error to Infallible. If you need Error, then use try_init!.

The syntax is identical to pin_init! and its safety caveats also apply:

  • unsafe code must guarantee either full initialization or return an error and allow deallocation of the memory.
  • the fields are initialized in the order given in the initializer.
  • no references to fields are allowed to be created inside of the initializer.

This initializer is for initializing data in-place that might later be moved. If you want to pin-initialize, use pin_init!.