Struct trillium::StateSet

source ·
pub struct StateSet(/* private fields */);
Expand description

Store and retrieve values by TypeId. This allows storing arbitrary data that implements Sync + Send + 'static.

Implementations§

source§

impl StateSet

source

pub fn new() -> StateSet

Create an empty StateSet.

source

pub fn insert<T>(&mut self, val: T) -> Option<T>
where T: Send + Sync + 'static,

Insert a value into this StateSet.

If a value of this type already exists, it will be returned.

source

pub fn contains<T>(&self) -> bool
where T: 'static,

Check if container contains value for type

source

pub fn get<T>(&self) -> Option<&T>
where T: 'static,

Get a reference to a value previously inserted on this StateSet.

source

pub fn get_mut<T>(&mut self) -> Option<&mut T>
where T: 'static,

Get a mutable reference to a value previously inserted on this StateSet.

source

pub fn take<T>(&mut self) -> Option<T>
where T: 'static,

Remove a value from this StateSet.

If a value of this type exists, it will be returned.

source

pub fn get_or_insert<T>(&mut self, default: T) -> &mut T
where T: Send + Sync + 'static,

Gets a value from this StateSet or populates it with the provided default.

source

pub fn get_or_insert_with<F, T>(&mut self, default: F) -> &mut T
where F: FnOnce() -> T, T: Send + Sync + 'static,

Gets a value from this StateSet or populates it with the provided default function.

Trait Implementations§

source§

impl AsMut<StateSet> for Conn

source§

fn as_mut(&mut self) -> &mut StateSet

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<StateSet> for Conn

source§

fn as_ref(&self) -> &StateSet

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Debug for StateSet

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for StateSet

source§

fn default() -> StateSet

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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>,

§

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>,

§

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.