Error

Enum Error 

Source
pub enum Error<'a, E> {
    UnclosedRegion {
        source: &'a str,
        range: Range<usize>,
    },
    UnexpectedClosingBrace {
        index: usize,
    },
    UnexpectedOpeningBrace {
        index: usize,
    },
    BadReplacement {
        key: &'a str,
        range: Range<usize>,
        error: E,
    },
    WriteFailed(Error),
}
Expand description

Any error that occurs when filling a template string.

Template parsing and filling is all done in a single pass; so a failed replacement due to an unknown key will shadow a syntax error later in the string.

Variants§

§

UnclosedRegion

A template region was not closed. That is, an opening curly brace ({) with no matching closing curly brace (}).

Example:

"Hello, {thing"

Fields

§source: &'a str

The text of the unclosed region, which will start with { and contain no other curly braces.

§range: Range<usize>

The indexes of source within the template string.

§

UnexpectedClosingBrace

An unescaped closing curly brace (}) was found, outside a template region.

Examples:

"Hello, thing}!"
"Hello, {name}, look at my magnificent moustache: (}-:"
"Hello, {name}}!"

Fields

§index: usize

The index of the closing brace within the template string.

§

UnexpectedOpeningBrace

An opening curly brace ({) was found within a template region.

Examples:

"Hello, {thing{{sadness}}}"

Fields

§index: usize

The index of the opening brace within the template string.

§

BadReplacement

The filler returned an error for the specified key.

Fields

§key: &'a str

The key on which the filler failed. Curly braces not included.

§range: Range<usize>

The indexes of key within the template string.

§error: E

The error value returned by the filler.

§

WriteFailed(Error)

Writing to the output failed.

Trait Implementations§

Source§

impl<'a, E: Debug> Debug for Error<'a, E>

Source§

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

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

impl<'a, E> Display for Error<'a, E>
where E: Display,

Source§

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

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

impl<'a, E> Error for Error<'a, E>
where E: Error + 'static,

Available on crate feature std only.
Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<'a, E> From<Error> for Error<'a, E>

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl<'a, E: PartialEq> PartialEq for Error<'a, E>

Source§

fn eq(&self, other: &Error<'a, E>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, E: Eq> Eq for Error<'a, E>

Source§

impl<'a, E> StructuralPartialEq for Error<'a, E>

Auto Trait Implementations§

§

impl<'a, E> Freeze for Error<'a, E>
where E: Freeze,

§

impl<'a, E> RefUnwindSafe for Error<'a, E>
where E: RefUnwindSafe,

§

impl<'a, E> Send for Error<'a, E>
where E: Send,

§

impl<'a, E> Sync for Error<'a, E>
where E: Sync,

§

impl<'a, E> Unpin for Error<'a, E>
where E: Unpin,

§

impl<'a, E> UnwindSafe for Error<'a, E>
where E: UnwindSafe,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.