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§
Sourcefn within(self, text: &'s str) -> Self
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.
Sourcefn regex(self, re: &'static str) -> Self
fn regex(self, re: &'static str) -> Self
Provide the regex which failed to match on the target slice.
Sourcefn regex_group(self, group: usize) -> Self
fn regex_group(self, group: usize) -> Self
Provide the capture group which contained the target slice.
Sourcefn message_outside(self, msg: impl Display) -> Self
fn message_outside(self, msg: impl Display) -> Self
Place an additional message outside of whatever context has already been provided.
Sourcefn message_inside(self, msg: impl Display) -> Self
fn message_inside(self, msg: impl Display) -> Self
Place an additional message inside of whatever context has already been provided.
Sourcefn replace_expected<A, B>(self) -> Self
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.
Sourcefn at_start(self) -> Self
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.
Sourcefn at_end(self) -> Self
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.