#[cfg(feature = "alloc")] use alloc::boxed::Box; use core::convert::Infallible; use core::error::Error as StdError; use core::fmt; use core::marker::PhantomData; #[cfg(feature = "std")] use std::io;
/// The [`Result`](std::result::Result) type with [`Error`] as default error type pubtype Result<I, E = Error> = core::result::Result<I, E>;
/// askama's error type /// /// Used as error value for e.g. [`Template::render()`][crate::Template::render()] /// and custom filters. #[non_exhaustive] #[derive(Debug)] pubenum Error { /// Generic, unspecified formatting error
Fmt, /// Key not present in [`Values`][crate::Values]
ValueMissing, /// Incompatible value type for key in [`Values`][crate::Values]
ValueType, /// An error raised by using `?` in a template #[cfg(feature = "alloc")]
Custom(Box<dyn StdError + Send + Sync>), /// JSON conversion error #[cfg(feature = "serde_json")]
Json(serde_json::Error),
}
/// Helper trait to convert a custom `?` call into a [`crate::Result`] pubtrait ResultConverter { /// Okay Value type of the output type Value; /// Input type type Input;
/// Consume an interior mutable `self`, and turn it into a [`crate::Result`] fn askama_conv_result(self, result: Self::Input) -> Result<Self::Value, Error>;
}
/// Helper marker to be used with [`ResultConverter`] #[derive(Debug, Clone, Copy)] pubstruct ErrorMarker<T>(PhantomData<Result<T>>);
impl<T> ErrorMarker<T> { /// Get marker for a [`Result`] type #[inline] pubfn of(_: &T) -> Self { Self(PhantomData)
}
}
#[cfg(feature = "alloc")] impl<T, E> ResultConverter for &ErrorMarker<Result<T, E>> where
E: Into<Box<dyn StdError + Send + Sync>>,
{ type Value = T; type Input = Result<T, E>;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.