Struct xpct::core::Matcher

source ·
pub struct Matcher<'a, In, PosOut, NegOut = PosOut> { /* private fields */ }
Expand description

A matcher.

This type is a matcher that can be used to make assertions. You can create a matcher from any type which implements Match or TransformMatch.

Implementations§

source§

impl<'a, Actual> Matcher<'a, Actual, Actual>

source

pub fn new<M, Fmt>(matcher: M, format: Fmt) -> Selfwhere M: Match<Actual> + 'a, Fmt: MatcherFormat<Pos = M::Fail, Neg = M::Fail> + 'a, Actual: 'a,

Create a new Matcher from a type that implements Match and a formatter.

source

pub fn neg<M, Fmt>(matcher: M, format: Fmt) -> Selfwhere M: Match<Actual> + 'a, Fmt: MatcherFormat<Pos = M::Fail, Neg = M::Fail> + 'a, Actual: 'a,

Same as new, but negates the matcher.

If you want to create a negated version of a matcher, such as a counterpart of equal called not_equal, you can use this method to do so.

source§

impl<'a, In, PosOut, NegOut> Matcher<'a, In, PosOut, NegOut>

source

pub fn transform<M, Fmt>(matcher: M, format: Fmt) -> Selfwhere M: TransformMatch<In = In, PosOut = PosOut, NegOut = NegOut> + 'a, Fmt: MatcherFormat<Pos = M::PosFail, Neg = M::NegFail> + 'a,

Create a new Matcher from a type that implements TransformMatch and a formatter.

source

pub fn transform_neg<M, Fmt>(matcher: M, format: Fmt) -> Selfwhere M: TransformMatch<In = In, PosOut = NegOut, NegOut = PosOut> + 'a, Fmt: MatcherFormat<Pos = M::NegFail, Neg = M::PosFail> + 'a,

Same as transform, but negates the matcher.

See neg.

source

pub fn wrapped<Fmt>(self, format: Fmt) -> Selfwhere In: 'a, PosOut: 'a, NegOut: 'a, Fmt: MatcherFormat<Pos = FormattedFailure, Neg = FormattedFailure> + 'a,

Wrap this matcher with a new formatter.

source

pub fn into_box(self) -> BoxTransformMatch<'a, In, PosOut, NegOut>

Convert this matcher into a BoxTransformMatch.

Trait Implementations§

source§

impl<'a, In, PosOut, NegOut> Debug for Matcher<'a, In, PosOut, NegOut>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, In, PosOut, NegOut> DynTransformMatch for Matcher<'a, In, PosOut, NegOut>

§

type In = In

§

type PosOut = PosOut

§

type NegOut = NegOut

source§

fn match_pos( self: Box<Self>, actual: Self::In ) -> Result<MatchOutcome<Self::PosOut, FormattedFailure>>

An object-safe version of TransformMatch::match_pos.
source§

fn match_neg( self: Box<Self>, actual: Self::In ) -> Result<MatchOutcome<Self::NegOut, FormattedFailure>>

An object-safe version of TransformMatch::match_neg.

Auto Trait Implementations§

§

impl<'a, In, PosOut, NegOut = PosOut> !RefUnwindSafe for Matcher<'a, In, PosOut, NegOut>

§

impl<'a, In, PosOut, NegOut = PosOut> !Send for Matcher<'a, In, PosOut, NegOut>

§

impl<'a, In, PosOut, NegOut = PosOut> !Sync for Matcher<'a, In, PosOut, NegOut>

§

impl<'a, In, PosOut, NegOut> Unpin for Matcher<'a, In, PosOut, NegOut>

§

impl<'a, In, PosOut, NegOut = PosOut> !UnwindSafe for Matcher<'a, In, PosOut, NegOut>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.