ResultExt

Trait ResultExt 

Source
pub trait ResultExt<'s> {
    // Required methods
    fn within(self, text: &'s str) -> Self;
    fn regex(self, re: &'static str) -> Self;
    fn regex_group(self, group: usize) -> Self;
    fn message_outside(self, msg: impl Display) -> Self;
    fn message_inside(self, msg: impl Display) -> Self;
    fn expected<T>(self) -> Self;
    fn replace_expected<A, B>(self) -> Self;
    fn at_start(self) -> Self;
    fn at_end(self) -> Self;
}
Expand description

An extension trait for InptResult, used to provide error context.

Required Methods§

Source

fn within(self, text: &'s str) -> Self

Provide a slice of the input text which is known to contain the error, and set that slice as the target of later context.

Source

fn regex(self, re: &'static str) -> Self

Provide the regex which failed to match on the target slice.

Source

fn regex_group(self, group: usize) -> Self

Provide the capture group which contained the target slice.

Source

fn message_outside(self, msg: impl Display) -> Self

Place an additional message outside of whatever context has already been provided.

Source

fn message_inside(self, msg: impl Display) -> Self

Place an additional message inside of whatever context has already been provided.

Source

fn expected<T>(self) -> Self

Provide the type which failed to parse from the target slice.

Source

fn replace_expected<A, B>(self) -> Self

Find the last occurance of type A provided by a call to ResultExt::expected and change it to B.

Source

fn at_start(self) -> Self

Rather than giving an exact slice to ResultExt::within, specify that the error is at the start of wathever slice is provided later.

Source

fn at_end(self) -> Self

Rather than giving an exact slice to ResultExt::within, specify that the error is at the end of wathever slice is provided later.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'s, R> ResultExt<'s> for InptResult<'s, R>