crux_core::testing

Struct Update

source
pub struct Update<Ef, Ev> {
    pub effects: Vec<Ef>,
    pub events: Vec<Ev>,
}
Expand description

Update test helper holds the result of running an app update using AppTester::update or resolving a request with AppTester::resolve.

Fields§

§effects: Vec<Ef>

Effects requested from the update run

§events: Vec<Ev>

Events dispatched from the update run

Implementations§

source§

impl<Ef, Ev> Update<Ef, Ev>

source

pub fn into_effects(self) -> impl Iterator<Item = Ef>

source

pub fn effects(&self) -> impl Iterator<Item = &Ef>

source

pub fn effects_mut(&mut self) -> impl Iterator<Item = &mut Ef>

source

pub fn expect_one_effect(self) -> Ef

Assert that the update contains exactly one effect and zero events, and return the effect

source

pub fn expect_one_event(self) -> Ev

Assert that the update contains exactly one event and zero effects, and return the event

source

pub fn assert_empty(self)

Assert that the update contains no effects or events

source

pub fn take_effects<P>(&mut self, predicate: P) -> VecDeque<Ef>
where P: FnMut(&Ef) -> bool,

Take effects matching the predicate out of the Update and return them, mutating the Update

source

pub fn take_effects_partitioned_by<P>( &mut self, predicate: P, ) -> (VecDeque<Ef>, VecDeque<Ef>)
where P: FnMut(&Ef) -> bool,

Take all of the effects out of the Update and split them into those matching predicate and the rest

Trait Implementations§

source§

impl<Ef: Debug, Ev: Debug> Debug for Update<Ef, Ev>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Ef, Ev> Freeze for Update<Ef, Ev>

§

impl<Ef, Ev> RefUnwindSafe for Update<Ef, Ev>

§

impl<Ef, Ev> Send for Update<Ef, Ev>
where Ef: Send, Ev: Send,

§

impl<Ef, Ev> Sync for Update<Ef, Ev>
where Ef: Sync, Ev: Sync,

§

impl<Ef, Ev> Unpin for Update<Ef, Ev>
where Ef: Unpin, Ev: Unpin,

§

impl<Ef, Ev> UnwindSafe for Update<Ef, Ev>
where Ef: UnwindSafe, Ev: 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.