pub unsafe trait InitStatus<T>: Copy {
    type Value;

    // Required methods
    fn init(out: &mut Self::Value, t: T);
    unsafe fn assume_init_ref(t: &Self::Value) -> &T;
    unsafe fn assume_init_mut(t: &mut Self::Value) -> &mut T;
}
Expand description

This trait is used to write code that may work on matrices that may or may not be initialized.

This trait is used to describe how a value must be accessed to initialize it or to retrieve a reference or mutable reference. Typically, a function accepting both initialized and uninitialized inputs should have a Status: InitStatus<T> type parameter. Then the methods of the Status can be used to access the element.

§Safety

This trait must not be implemented outside of this crate.

Required Associated Types§

source

type Value

The type of the values with the initialization status described by Self.

Required Methods§

source

fn init(out: &mut Self::Value, t: T)

Initialize the given element.

source

unsafe fn assume_init_ref(t: &Self::Value) -> &T

Retrieve a reference to the element, assuming that it is initialized.

§Safety

This is unsound if the referenced value isn’t initialized.

source

unsafe fn assume_init_mut(t: &mut Self::Value) -> &mut T

Retrieve a mutable reference to the element, assuming that it is initialized.

§Safety

This is unsound if the referenced value isn’t initialized.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> InitStatus<T> for Init

§

type Value = T

source§

impl<T> InitStatus<T> for Uninit