]>
git.proxmox.com Git - rustc.git/blob - vendor/serde/src/std_error.rs
1 use crate::lib
::{Debug, Display}
;
3 /// Either a re-export of std::error::Error or a new identical trait, depending
4 /// on whether Serde's "std" feature is enabled.
6 /// Serde's error traits [`serde::ser::Error`] and [`serde::de::Error`] require
7 /// [`std::error::Error`] as a supertrait, but only when Serde is built with
8 /// "std" enabled. Data formats that don't care about no\_std support should
9 /// generally provide their error types with a `std::error::Error` impl
14 /// struct MySerError {...}
16 /// impl serde::ser::Error for MySerError {...}
18 /// impl std::fmt::Display for MySerError {...}
20 /// // We don't support no_std!
21 /// impl std::error::Error for MySerError {}
24 /// Data formats that *do* support no\_std may either have a "std" feature of
29 /// std = ["serde/std"]
33 /// #[cfg(feature = "std")]
34 /// impl std::error::Error for MySerError {}
37 /// ... or else provide the std Error impl unconditionally via Serde's
41 /// impl serde::ser::StdError for MySerError {}
43 pub trait Error
: Debug
+ Display
{
44 /// The underlying cause of this error, if any.
45 fn source(&self) -> Option
<&(Error
+ '
static)> {