mirror of
https://github.com/serde-rs/serde.git
synced 2025-10-02 07:21:12 +00:00
Keep Debug and Display as supertraits even in no_std
This commit is contained in:
parent
21c2119349
commit
a581c0d147
@ -101,6 +101,8 @@ use std::error;
|
||||
use collections::{String, Vec};
|
||||
|
||||
use core::fmt::{self, Display};
|
||||
#[cfg(not(feature = "std"))]
|
||||
use core::fmt::Debug;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -122,7 +124,7 @@ pub use self::ignored_any::IgnoredAny;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
macro_rules! declare_error_trait {
|
||||
(Error: Sized $(+ $($supertrait:ident)::*)*) => {
|
||||
(Error: Sized $(+ $($supertrait:ident)::+)*) => {
|
||||
/// The `Error` trait allows `Deserialize` implementations to create descriptive
|
||||
/// error messages belonging to the `Deserializer` against which they are
|
||||
/// currently running.
|
||||
@ -136,7 +138,7 @@ macro_rules! declare_error_trait {
|
||||
///
|
||||
/// Most deserializers should only need to provide the `Error::custom` method
|
||||
/// and inherit the default behavior for the other methods.
|
||||
pub trait Error: Sized $(+ $($supertrait)::*)* {
|
||||
pub trait Error: Sized $(+ $($supertrait)::+)* {
|
||||
/// Raised when there is general error when deserializing a type.
|
||||
///
|
||||
/// The message should not be capitalized and should not end with a period.
|
||||
@ -254,7 +256,7 @@ macro_rules! declare_error_trait {
|
||||
declare_error_trait!(Error: Sized + error::Error);
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
declare_error_trait!(Error: Sized);
|
||||
declare_error_trait!(Error: Sized + Debug + Display);
|
||||
|
||||
/// `Unexpected` represents an unexpected invocation of any one of the `Visitor`
|
||||
/// trait methods.
|
||||
|
@ -97,6 +97,8 @@ use std::error;
|
||||
|
||||
#[cfg(all(feature = "collections", not(feature = "std")))]
|
||||
use collections::string::String;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use core::fmt::Debug;
|
||||
use core::fmt::Display;
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
use core::fmt::Write;
|
||||
@ -116,11 +118,11 @@ pub use self::impossible::Impossible;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
macro_rules! declare_error_trait {
|
||||
(Error: Sized $(+ $($supertrait:ident)::*)*) => {
|
||||
(Error: Sized $(+ $($supertrait:ident)::+)*) => {
|
||||
/// Trait used by `Serialize` implementations to generically construct
|
||||
/// errors belonging to the `Serializer` against which they are
|
||||
/// currently running.
|
||||
pub trait Error: Sized $(+ $($supertrait)::*)* {
|
||||
pub trait Error: Sized $(+ $($supertrait)::+)* {
|
||||
/// Raised when a `Serialize` implementation encounters a general
|
||||
/// error while serializing a type.
|
||||
///
|
||||
@ -154,7 +156,7 @@ macro_rules! declare_error_trait {
|
||||
declare_error_trait!(Error: Sized + error::Error);
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
declare_error_trait!(Error: Sized);
|
||||
declare_error_trait!(Error: Sized + Debug + Display);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user