rxpect

Trait ExpectProjection

Source
pub trait ExpectProjection<'e, F, T, U, B>
where F: Fn(&T) -> U + 'e, T: Debug + 'e, U: Debug + 'e, B: ExpectationBuilder<'e, U>,
{ // Required method fn projected_by(self, projection: F, config: impl FnOnce(B) -> B) -> Self; }

Required Methods§

Source

fn projected_by(self, projection: F, config: impl FnOnce(B) -> B) -> Self

Add expectations on a projected value

use rxpect::expect;
use rxpect::expectations::EqualityExpectations;
use rxpect::ExpectProjection;

#[derive(Debug)]
pub struct MyStruct {
    pub foo: u32
}
expect(MyStruct{ foo: 7 }).projected_by(|it| it.foo, |foo| foo
    .to_equal(7)
);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§