diff --git a/serde/build.rs b/serde/build.rs index 82129bc7..e27e2f34 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -23,6 +23,12 @@ fn main() { println!("cargo:rustc-cfg=collections_bound"); } + // core::cmp::Reverse stabilized in Rust 1.19: + // https://doc.rust-lang.org/stable/core/cmp/struct.Reverse.html + if minor >= 19 { + println!("cargo:rustc-cfg=core_reverse"); + } + // CString::into_boxed_c_str stabilized in Rust 1.20: // https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str if minor >= 20 { diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 9a036180..1c18fd96 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -578,6 +578,7 @@ macro_rules! forwarded_impl { #[cfg(all(feature = "std", de_boxed_c_str))] forwarded_impl!((), Box, CString::into_boxed_c_str); +#[cfg(core_reverse)] forwarded_impl!((T), Reverse, Reverse); //////////////////////////////////////////////////////////////////////////////// diff --git a/serde/src/lib.rs b/serde/src/lib.rs index 21a8ecd9..17d07dc3 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -139,6 +139,7 @@ mod lib { pub use self::core::cell::{Cell, RefCell}; pub use self::core::clone::{self, Clone}; + #[cfg(core_reverse)] pub use self::core::cmp::Reverse; pub use self::core::convert::{self, From, Into}; pub use self::core::default::{self, Default}; diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index a8dd49bf..46d406b2 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -825,6 +825,7 @@ where } } +#[cfg(core_reverse)] impl Serialize for Reverse where T: Serialize,