Struct kernel::utilities::static_init::StaticUninitializedBuffer
source · [−]pub struct StaticUninitializedBuffer<T: 'static> { /* private fields */ }
Expand description
The StaticUninitializedBuffer
type represents a statically allocated
buffer that can be converted to another type once it has been initialized.
Upon initialization, a static mutable reference is returned and the
StaticUninitializedBuffer
is consumed.
This type is implemented as a wrapper containing a static mutable reference to
an UninitializedBuffer
. This guarantees that the memory pointed to by the
reference has not already been initialized.
StaticUninitializedBuffer
provides one operation: initialize()
that returns a
&'static mut T
reference. This is the only way to get the reference, and
ensures that the underlying uninitialized buffer is properly initialized.
The wrapper is also consumed when initialize()
is called, ensuring that
the underlying memory cannot be subsequently re-initialized.
Implementations
sourceimpl<T> StaticUninitializedBuffer<T>
impl<T> StaticUninitializedBuffer<T>
sourcepub fn new(buf: &'static mut UninitializedBuffer<T>) -> Self
pub fn new(buf: &'static mut UninitializedBuffer<T>) -> Self
This function is not intended to be called publicly. It’s only meant to
be called within static_buf!
macro, but Rust’s visibility rules
require it to be public, so that the macro’s body can be instantiated.
sourcepub unsafe fn initialize(self, value: T) -> &'static mut T
pub unsafe fn initialize(self, value: T) -> &'static mut T
This function consumes an uninitialized static buffer, initializes it
to some value, and returns a static mutable reference to it. This
allows for runtime initialization of static
values that do not have a
const
constructor.
Auto Trait Implementations
impl<T> RefUnwindSafe for StaticUninitializedBuffer<T> where
T: RefUnwindSafe,
impl<T> Send for StaticUninitializedBuffer<T> where
T: Send,
impl<T> Sync for StaticUninitializedBuffer<T> where
T: Sync,
impl<T> Unpin for StaticUninitializedBuffer<T>
impl<T> !UnwindSafe for StaticUninitializedBuffer<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more