Struct Should
Source pub struct Should<'a, T> { }
Expand description
A wrapper type that provides fluent-style assertions for a given value.
Constructed using the Shouldable::should method.
Asserts that the value is true.
§Examples
use shoulds::Shouldable;
let value = true;
value.should().be_true();
§Panics
Panics if the actual value is not true.
Asserts that the value is false.
§Examples
use shoulds::Shouldable;
let value = false;
value.should().be_false();
§Panics
Panics if the actual value is not false.
Asserts that the value is equal to the expected value.
§Examples
use shoulds::Shouldable;
let value = 42;
value.should().eq(&42);
§Panics
Panics if the actual value is not equal to the expected value.
Asserts that the value is not equal to the expected value.
§Examples
use shoulds::Shouldable;
let value = 42;
value.should().ne(&43);
§Panics
Panics if the actual value is equal to the expected value.
Asserts that the Option is Some.
§Examples
use shoulds::Shouldable;
let value: Option<i32> = Some(42);
value.should().be_some();
§Panics
Panics if the Option is None.
Asserts that the Option is None.
§Examples
use shoulds::Shouldable;
let value: Option<i32> = None;
value.should().be_none();
§Panics
Panics if the Option is Some.
Asserts that the Result is Ok.
§Examples
use shoulds::Shouldable;
let result: Result<i32, &str> = Ok(42);
result.should().be_ok();
§Panics
Panics if the Result is an Err.
Asserts that the Result is Err.
§Examples
use shoulds::Shouldable;
let result: Result<i32, &str> = Err("error");
result.should().be_err();
§Panics
Panics if the Result is Ok.
Source§Returns a reference to the underlying value.
This can be useful for writing custom assertions or debugging.
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From<T> for U chooses to do.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.