Expectation

Struct Expectation 

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

Wrapper for making assertions.

Implementations§

Source§

impl<T> Expectation<T>

Source

pub fn not(self) -> Self

Negate the expectation.

Source§

impl<T: PartialEq + Debug> Expectation<T>

Source

pub fn to_equal(self, expected: T)

Assert equality.

Source§

impl<T: PartialOrd + Debug> Expectation<T>

Source

pub fn to_be_greater_than(self, other: T)

Assert greater than.

Source

pub fn to_be_less_than(self, other: T)

Assert less than.

Source§

impl Expectation<bool>

Source

pub fn to_be_true(self)

Assert true.

Source

pub fn to_be_false(self)

Assert false.

Source§

impl<T> Expectation<Option<T>>

Source

pub fn to_be_some(self)

Assert Some.

Source

pub fn to_be_none(self)

Assert None.

Source§

impl<T, E> Expectation<Result<T, E>>

Source

pub fn to_be_ok(self)

Assert Ok.

Source

pub fn to_be_err(self)

Assert Err.

Source§

impl<T> Expectation<Vec<T>>

Source

pub fn to_be_empty(self)

Assert empty.

Source

pub fn to_have_length(self, expected: usize)

Assert length.

Source§

impl Expectation<&str>

Source

pub fn to_contain(self, needle: &str)

Assert contains.

Source

pub fn to_start_with(self, prefix: &str)

Assert starts with.

Source

pub fn to_end_with(self, suffix: &str)

Assert ends with.

Source§

impl Expectation<String>

Source

pub fn to_contain(self, needle: &str)

Assert contains.

Source

pub fn to_be_empty(self)

Assert empty.

Source§

impl Expectation<f32>

Source

pub fn to_be_close_to(self, expected: f32, epsilon: f32)

Assert close to (within epsilon).

Source§

impl Expectation<f64>

Source

pub fn to_be_close_to(self, expected: f64, epsilon: f64)

Assert close to (within epsilon).

Auto Trait Implementations§

§

impl<T> Freeze for Expectation<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Expectation<T>
where T: RefUnwindSafe,

§

impl<T> Send for Expectation<T>
where T: Send,

§

impl<T> Sync for Expectation<T>
where T: Sync,

§

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

§

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

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.