Skip to main content

SoftAsserter

Struct SoftAsserter 

Source
pub struct SoftAsserter { /* private fields */ }
Expand description

The recorder passed to a soft closure.

Every check/record that fails is pushed onto an internal list instead of returning early; soft turns that list into one TestError on scope exit. Callers rarely construct or name this type directly: it arrives as the argument of the soft closure.

Implementations§

Source§

impl SoftAsserter

Source

pub fn new() -> SoftAsserter

Creates an empty recorder. Most callers use soft rather than constructing this directly.

Source

pub fn check<T, M>(&mut self, actual: &T, matcher: M)
where M: Matcher<T>, T: ?Sized,

Records whether actual satisfies matcher. A miss is collected, not propagated, so the closure keeps running.

The recorded failure captures this call site, so each soft failure reports the line it came from. The soft counterpart of Subject::satisfies.

Source

pub fn record(&mut self, result: Result<(), TestError>)

Records the result of an arbitrary fallible step. An Err is collected with its original location and context intact; an Ok is ignored.

Source

pub fn context( &mut self, message: impl Into<Cow<'static, str>>, ) -> SoftScope<'_>

Opens a context sub-scope. Failures recorded through the returned SoftScope carry message as a context frame; the frame is removed when the SoftScope is dropped. Sub-scopes nest: a SoftScope can open further sub-scopes, and their frames stack outermost-first.

Trait Implementations§

Source§

impl Default for SoftAsserter

Source§

fn default() -> SoftAsserter

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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