serde v1.0.100 Release Notes

Release Date: 2019-09-08 // over 4 years ago

    Provide serde::ser::StdError and serde::de::StdError which are either a re-export of std::error::Error (if Serde's "std" feature is enabled) or a new identical trait (otherwise).

    #[cfg(feature = "std")]pub use std::error::Error as StdError; #[cfg(not(feature = "std"))]pub trait StdError: Debug + Display { fn source(&self) -\> Option\<&(StdError + 'static)\> { None } }
    

    👍 Serde's error traits serde::ser::Error and serde::de::Error require std::error::Error as a supertrait, but only when Serde is built with "std" enabled. Data formats that don't care about no_std support should generally provide their error types with a std::error::Error impl directly:

    #[derive(Debug)]struct MySerError {...}impl serde::ser::Error for MySerError {...}impl std::fmt::Display for MySerError {...}// We don't support no\_std!impl std::error::Error for MySerError {}
    

    Data formats that do support no_std may either have a "std" feature of their own as has been required in the past:

    [features]std = ["serde/std"]
    
    #[cfg(feature = "std")]impl std::error::Error for MySerError {}
    

    ... or else now may provide the std Error impl unconditionally via Serde's re-export:

    impl serde::ser::StdError for MySerError {}