LocalStatic

Struct LocalStatic 

Source
pub struct LocalStatic<T> { /* private fields */ }
Expand description

A struct for storing local variables in static storage.

LocalStatic provides a way to store local variables in static storage, allowing them to be initialized and accessed at runtime. This type is useful when you need to store mutable state in a static context, such as in embedded systems.

Implementations§

Source§

impl<T> LocalStatic<T>

Source

pub const fn new() -> Self

Creates a new LocalStatic instance, with the memory being filled with 0 bytes.

§Returns

A new LocalStatic instance containing an uninitialized value of type T.

Source

pub const fn with(val: T) -> Self

Creates a new LocalStatic instance, initialized with the given value.

§Parameters
  • val: The value to initialize the LocalStatic with.
§Returns

A new LocalStatic instance containing the given val.

Source

pub fn get(&'static self) -> &'static T

Gets an immutable reference to the value stored in LocalStatic.

§Returns

An immutable reference to the value stored in LocalStatic.

Source

pub fn get_mut(&'static self) -> &'static mut T

Gets a mutable reference to the value stored in LocalStatic.

§Returns

A mutable reference to the value stored in LocalStatic.

Source

pub fn set(&'static self, val: T)

Sets the value stored in LocalStatic to the given value.

§Parameters
  • val: The value to set the LocalStatic to.

Trait Implementations§

Source§

impl<T> Send for LocalStatic<T>

Source§

impl<T> Sync for LocalStatic<T>

Auto Trait Implementations§

§

impl<T> !Freeze for LocalStatic<T>

§

impl<T> !RefUnwindSafe for LocalStatic<T>

§

impl<T> Unpin for LocalStatic<T>
where T: Unpin,

§

impl<T> UnwindSafe for LocalStatic<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.