[][src]Struct assert4rs::Assert

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

Implementations

impl<T> Assert<T>[src]

Entry point for the Assert DSL.

Assert provides a fluent API for assertions. An Assert holds the actual value that can be used in assertion statements.

Assert::that(3).is(3);

pub fn that(actual: T) -> Self[src]

Create an Assert instance for the actual value.

All assertions start with Assert::that(actual).

pub fn map<R>(self, f: impl Fn(T) -> R) -> Assert<R>[src]

Maps the actual value using lambda f.

This method is intended to map the actual value in order to apply further assertions.

Assert::that("3")
    .map(|v| v.parse::<i32>().unwrap())
    .is(3);

impl<T> Assert<Option<T>> where
    T: PartialEq + Debug
[src]

DSL for Option assertions.

pub fn is_some(self, expected: T) -> Self[src]

Assert that actual is equal to Some `expected' value.

pub fn is_none(self) -> Self[src]

Assert that actual is equal to None.

pub fn unwrap(self) -> Assert<T>[src]

Unwrap the Option value, panic for None.

impl<T> Assert<Vec<T>> where
    T: PartialEq + Debug
[src]

Assert DSL for Vec.

pub fn contains(self, expected: T) -> Self[src]

Assert that the actual vector contains a specific expected value.

Assert::that(vec![1, 2, 3]).contains(2);

pub fn get(&mut self, index: usize) -> Assert<Option<T>>[src]

Returns an Assert for a value from the Vec.

Assert::that(vec!['a', 'b', 'c']).get(1).is_some('b');
Assert::that(vec!['a', 'b', 'c']).get(5).is_none();

Trait Implementations

impl<T, R> AssertEquals<R> for Assert<T> where
    T: PartialEq<R> + Debug,
    R: Debug
[src]

Default implementation of AssertEquals.

Auto Trait Implementations

impl<T> RefUnwindSafe for Assert<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for Assert<T> where
    T: Send
[src]

impl<T> Sync for Assert<T> where
    T: Sync
[src]

impl<T> Unpin for Assert<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Assert<T> where
    T: UnwindSafe
[src]

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