Skip to main content

ExpectedErrorMessageBuilder

Struct ExpectedErrorMessageBuilder 

Source
pub struct ExpectedErrorMessageBuilder<'a> { /* private fields */ }
Available on crate feature test-util only.
Expand description

Builder struct for ExpectedErrorMessage

Implementations§

Source§

impl<'a> ExpectedErrorMessageBuilder<'a>

Source

pub fn error(msg: &'a str) -> Self

Create a builder expecting the given main error message (contents of Display)

Source

pub fn error_starts_with(msg: &'a str) -> Self

Create a builder expecting the main error message (contents of Display) to start with the given text.

(If you later add expected help text to this builder, that will also be an expected prefix, not the entire expected help text.)

Source

pub fn help(self, msg: &'a str) -> Self

Add expected contents of help(), or expected prefix of help() if this builder was originally constructed with error_starts_with()

Source

pub fn exactly_one_underline(self, snippet: &'a str) -> Self

Add expected underlined text. The error message will be expected to have exactly one miette label, and the underlined portion should be snippet. The underlined text should have no associated label text.

Source

pub fn exactly_one_underline_with_label( self, snippet: &'a str, label: &'a str, ) -> Self

Add expected underlined text. The error message will be expected to have exactly one miette label, and the underlined portion should be snippet. The label text is expected to match label.

Source

pub fn exactly_two_underlines( self, snippet1: &'a str, snippet2: &'a str, ) -> Self

Add expected underlined text. The error message will be expected to have exactly two miette labels, and the underlined portions should be snippet1 and snippet2, in that order. Both labels should have no associated label text.

Source

pub fn with_underlines_or_labels( self, labels: impl IntoIterator<Item = (&'a str, Option<&'a str>)>, ) -> Self

Add expected underlined text. The error message will be expected to have exactly this many miette labels, and for each label (a, b), the underlined portion should be a and the label text should be b (or None for no label text).

Source

pub fn source(self, msg: &'a str) -> Self

Add expected contents of source(), or expected prefix of source() if this builder was originally constructed with error_starts_with()

Source

pub fn build(self) -> ExpectedErrorMessage<'a>

Trait Implementations§

Source§

impl<'a> Debug for ExpectedErrorMessageBuilder<'a>

Source§

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

Formats the value using the given formatter. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.