[][src]Struct valerie::state::StateAtomic

pub struct StateAtomic<T> { /* fields omitted */ }

State variable to be used with types that implement Copy

This uses AtomicCell of crossbeam internally.

Implementations

impl<T> StateAtomic<T>[src]

pub fn new(value: T) -> Self[src]

Make a new StateAtomic variable.

Examples

let state = StateAtomic::new(0);
h3!(state)

impl<T> StateAtomic<T> where
    T: Display + Copy + 'static, 
[src]

pub fn from<U, F>(state: &U, func: F) -> Self where
    U: StateTrait + 'static,
    F: FnMut(U::Value) -> Self::Value + 'static, 
[src]

Derive a StateAtomic variable from another variable implementing StateTrait.

Examples

let counter = StateAtomic::new(1);
let double_counter = StateAtomic::from(&counter, |x| x * 2);

div!(
    h3!("Single count ", counter),
    h3!("Double count ", double_counter)
)

Trait Implementations

impl<T, U> Add<U> for StateAtomic<T> where
    T: Display + Copy + Add<U> + AddAssign<U>, 
[src]

type Output = Self

The resulting type after applying the + operator.

impl<T, U> AddAssign<U> for StateAtomic<T> where
    T: Display + Copy + AddAssign<U>, 
[src]

impl<T> Clone for StateAtomic<T>[src]

impl<T> Component for StateAtomic<T> where
    T: Display + Copy
[src]

impl<T, U> Div<U> for StateAtomic<T> where
    T: Display + Copy + Div<U> + DivAssign<U>, 
[src]

type Output = Self

The resulting type after applying the / operator.

impl<T, U> DivAssign<U> for StateAtomic<T> where
    T: Display + Copy + DivAssign<U>, 
[src]

impl<T> Eq for StateAtomic<T>[src]

impl<T> From<StateAtomic<T>> for Node where
    T: Display + Copy
[src]

impl<T, U> Mul<U> for StateAtomic<T> where
    T: Display + Copy + Mul<U> + MulAssign<U>, 
[src]

type Output = Self

The resulting type after applying the * operator.

impl<T, U> MulAssign<U> for StateAtomic<T> where
    T: Display + Copy + MulAssign<U>, 
[src]

impl<T> PartialEq<StateAtomic<T>> for StateAtomic<T>[src]

impl<T, U> Rem<U> for StateAtomic<T> where
    T: Display + Copy + Rem<U> + RemAssign<U>, 
[src]

type Output = Self

The resulting type after applying the % operator.

impl<T, U> RemAssign<U> for StateAtomic<T> where
    T: Display + Copy + RemAssign<U>, 
[src]

impl<T> StateTrait for StateAtomic<T> where
    T: Display + Copy
[src]

type Value = T

Type that is stored in the State variable.

type Store = AtomicCell<T>

Type that is wrapped in Arc which stores the value.

type Channel = Channel

Channel type is used to pass the message between the Sender and the Receiver.

impl<T, U> Sub<U> for StateAtomic<T> where
    T: Display + Copy + Sub<U> + SubAssign<U>, 
[src]

type Output = Self

The resulting type after applying the - operator.

impl<T, U> SubAssign<U> for StateAtomic<T> where
    T: Display + Copy + SubAssign<U>, 
[src]

impl<T> Value for StateAtomic<T> where
    T: Copy + Display
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for StateAtomic<T>

impl<T> Send for StateAtomic<T> where
    T: Send

impl<T> Sync for StateAtomic<T> where
    T: Send

impl<T> Unpin for StateAtomic<T>

impl<T> !UnwindSafe for StateAtomic<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.