mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 23:01:01 +00:00
Invert all build.rs cfgs
This allows non-Cargo builds to generally not get involved in cfgs. As long as one is using a reasonably recent toolchain, no cfgs need to be set and you'll get a fully-featured build.
This commit is contained in:
+44
-43
@@ -17,37 +17,38 @@ fn main() {
|
|||||||
// std::collections::Bound was stabilized in Rust 1.17
|
// std::collections::Bound was stabilized in Rust 1.17
|
||||||
// but it was moved to core::ops later in Rust 1.26:
|
// but it was moved to core::ops later in Rust 1.26:
|
||||||
// https://doc.rust-lang.org/core/ops/enum.Bound.html
|
// https://doc.rust-lang.org/core/ops/enum.Bound.html
|
||||||
if minor >= 26 {
|
if minor < 26 {
|
||||||
println!("cargo:rustc-cfg=ops_bound");
|
println!("cargo:rustc-cfg=no_ops_bound");
|
||||||
} else if minor >= 17 && cfg!(feature = "std") {
|
if minor < 17 {
|
||||||
println!("cargo:rustc-cfg=collections_bound");
|
println!("cargo:rustc-cfg=no_collections_bound");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// core::cmp::Reverse stabilized in Rust 1.19:
|
// core::cmp::Reverse stabilized in Rust 1.19:
|
||||||
// https://doc.rust-lang.org/stable/core/cmp/struct.Reverse.html
|
// https://doc.rust-lang.org/stable/core/cmp/struct.Reverse.html
|
||||||
if minor >= 19 {
|
if minor < 19 {
|
||||||
println!("cargo:rustc-cfg=core_reverse");
|
println!("cargo:rustc-cfg=no_core_reverse");
|
||||||
}
|
}
|
||||||
|
|
||||||
// CString::into_boxed_c_str and PathBuf::into_boxed_path stabilized in Rust 1.20:
|
// CString::into_boxed_c_str and PathBuf::into_boxed_path stabilized in Rust 1.20:
|
||||||
// https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str
|
// https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str
|
||||||
// https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.into_boxed_path
|
// https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.into_boxed_path
|
||||||
if minor >= 20 {
|
if minor < 20 {
|
||||||
println!("cargo:rustc-cfg=de_boxed_c_str");
|
println!("cargo:rustc-cfg=no_de_boxed_c_str");
|
||||||
println!("cargo:rustc-cfg=de_boxed_path");
|
println!("cargo:rustc-cfg=no_de_boxed_path");
|
||||||
}
|
}
|
||||||
|
|
||||||
// From<Box<T>> for Rc<T> / Arc<T> stabilized in Rust 1.21:
|
// From<Box<T>> for Rc<T> / Arc<T> stabilized in Rust 1.21:
|
||||||
// https://doc.rust-lang.org/std/rc/struct.Rc.html#impl-From<Box<T>>
|
// https://doc.rust-lang.org/std/rc/struct.Rc.html#impl-From<Box<T>>
|
||||||
// https://doc.rust-lang.org/std/sync/struct.Arc.html#impl-From<Box<T>>
|
// https://doc.rust-lang.org/std/sync/struct.Arc.html#impl-From<Box<T>>
|
||||||
if minor >= 21 {
|
if minor < 21 {
|
||||||
println!("cargo:rustc-cfg=de_rc_dst");
|
println!("cargo:rustc-cfg=no_de_rc_dst");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duration available in core since Rust 1.25:
|
// Duration available in core since Rust 1.25:
|
||||||
// https://blog.rust-lang.org/2018/03/29/Rust-1.25.html#library-stabilizations
|
// https://blog.rust-lang.org/2018/03/29/Rust-1.25.html#library-stabilizations
|
||||||
if minor >= 25 {
|
if minor < 25 {
|
||||||
println!("cargo:rustc-cfg=core_duration");
|
println!("cargo:rustc-cfg=no_core_duration");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 128-bit integers stabilized in Rust 1.26:
|
// 128-bit integers stabilized in Rust 1.26:
|
||||||
@@ -56,56 +57,56 @@ fn main() {
|
|||||||
// Disabled on Emscripten targets before Rust 1.40 since
|
// Disabled on Emscripten targets before Rust 1.40 since
|
||||||
// Emscripten did not support 128-bit integers until Rust 1.40
|
// Emscripten did not support 128-bit integers until Rust 1.40
|
||||||
// (https://github.com/rust-lang/rust/pull/65251)
|
// (https://github.com/rust-lang/rust/pull/65251)
|
||||||
if minor >= 26 && (!emscripten || minor >= 40) {
|
if minor < 26 || emscripten && minor < 40 {
|
||||||
println!("cargo:rustc-cfg=integer128");
|
println!("cargo:rustc-cfg=no_integer128");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inclusive ranges methods stabilized in Rust 1.27:
|
// Inclusive ranges methods stabilized in Rust 1.27:
|
||||||
// https://github.com/rust-lang/rust/pull/50758
|
// https://github.com/rust-lang/rust/pull/50758
|
||||||
// Also Iterator::try_for_each:
|
// Also Iterator::try_for_each:
|
||||||
// https://blog.rust-lang.org/2018/06/21/Rust-1.27.html#library-stabilizations
|
// https://blog.rust-lang.org/2018/06/21/Rust-1.27.html#library-stabilizations
|
||||||
if minor >= 27 {
|
if minor < 27 {
|
||||||
println!("cargo:rustc-cfg=range_inclusive");
|
println!("cargo:rustc-cfg=no_range_inclusive");
|
||||||
println!("cargo:rustc-cfg=iterator_try_fold");
|
println!("cargo:rustc-cfg=no_iterator_try_fold");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Non-zero integers stabilized in Rust 1.28:
|
// Non-zero integers stabilized in Rust 1.28:
|
||||||
// https://blog.rust-lang.org/2018/08/02/Rust-1.28.html#library-stabilizations
|
// https://blog.rust-lang.org/2018/08/02/Rust-1.28.html#library-stabilizations
|
||||||
if minor >= 28 {
|
if minor < 28 {
|
||||||
println!("cargo:rustc-cfg=num_nonzero");
|
println!("cargo:rustc-cfg=no_num_nonzero");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Current minimum supported version of serde_derive crate is Rust 1.31.
|
// Current minimum supported version of serde_derive crate is Rust 1.31.
|
||||||
if minor >= 31 {
|
if minor < 31 {
|
||||||
println!("cargo:rustc-cfg=serde_derive");
|
println!("cargo:rustc-cfg=no_serde_derive");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TryFrom, Atomic types, non-zero signed integers, and SystemTime::checked_add
|
// TryFrom, Atomic types, non-zero signed integers, and SystemTime::checked_add
|
||||||
// stabilized in Rust 1.34:
|
// stabilized in Rust 1.34:
|
||||||
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#tryfrom-and-tryinto
|
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#tryfrom-and-tryinto
|
||||||
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#library-stabilizations
|
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#library-stabilizations
|
||||||
if minor >= 34 {
|
if minor < 34 {
|
||||||
println!("cargo:rustc-cfg=core_try_from");
|
println!("cargo:rustc-cfg=no_core_try_from");
|
||||||
println!("cargo:rustc-cfg=num_nonzero_signed");
|
println!("cargo:rustc-cfg=no_num_nonzero_signed");
|
||||||
println!("cargo:rustc-cfg=systemtime_checked_add");
|
println!("cargo:rustc-cfg=no_systemtime_checked_add");
|
||||||
|
}
|
||||||
|
|
||||||
// Whitelist of archs that support std::sync::atomic module. Ideally we
|
// Whitelist of archs that support std::sync::atomic module. Ideally we
|
||||||
// would use #[cfg(target_has_atomic = "...")] but it is not stable yet.
|
// would use #[cfg(target_has_atomic = "...")] but it is not stable yet.
|
||||||
// Instead this is based on rustc's compiler/rustc_target/src/spec/*.rs.
|
// Instead this is based on rustc's compiler/rustc_target/src/spec/*.rs.
|
||||||
let has_atomic64 = target.starts_with("x86_64")
|
let has_atomic64 = target.starts_with("x86_64")
|
||||||
|| target.starts_with("i686")
|
|| target.starts_with("i686")
|
||||||
|| target.starts_with("aarch64")
|
|| target.starts_with("aarch64")
|
||||||
|| target.starts_with("powerpc64")
|
|| target.starts_with("powerpc64")
|
||||||
|| target.starts_with("sparc64")
|
|| target.starts_with("sparc64")
|
||||||
|| target.starts_with("mips64el")
|
|| target.starts_with("mips64el")
|
||||||
|| target.starts_with("riscv64");
|
|| target.starts_with("riscv64");
|
||||||
let has_atomic32 = has_atomic64 || emscripten;
|
let has_atomic32 = has_atomic64 || emscripten;
|
||||||
if has_atomic64 {
|
if minor < 34 || !has_atomic64 {
|
||||||
println!("cargo:rustc-cfg=std_atomic64");
|
println!("cargo:rustc-cfg=no_std_atomic64");
|
||||||
}
|
}
|
||||||
if has_atomic32 {
|
if minor < 34 || !has_atomic32 {
|
||||||
println!("cargo:rustc-cfg=std_atomic");
|
println!("cargo:rustc-cfg=no_std_atomic");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+32
-28
@@ -4,7 +4,7 @@ use de::{
|
|||||||
Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess, Visitor,
|
Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess, Visitor,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(core_duration, feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc", not(no_core_duration)))]
|
||||||
use de::MapAccess;
|
use de::MapAccess;
|
||||||
|
|
||||||
use seed::InPlaceSeed;
|
use seed::InPlaceSeed;
|
||||||
@@ -637,10 +637,10 @@ macro_rules! forwarded_impl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", de_boxed_c_str))]
|
#[cfg(all(feature = "std", not(no_de_boxed_c_str)))]
|
||||||
forwarded_impl!((), Box<CStr>, CString::into_boxed_c_str);
|
forwarded_impl!((), Box<CStr>, CString::into_boxed_c_str);
|
||||||
|
|
||||||
#[cfg(core_reverse)]
|
#[cfg(not(no_core_reverse))]
|
||||||
forwarded_impl!((T), Reverse<T>, Reverse);
|
forwarded_impl!((T), Reverse<T>, Reverse);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -1604,7 +1604,7 @@ impl<'de> Deserialize<'de> for PathBuf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", de_boxed_path))]
|
#[cfg(all(feature = "std", not(no_de_boxed_path)))]
|
||||||
forwarded_impl!((), Box<Path>, PathBuf::into_boxed_path);
|
forwarded_impl!((), Box<Path>, PathBuf::into_boxed_path);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -1685,11 +1685,7 @@ forwarded_impl!((T), Box<[T]>, Vec::into_boxed_slice);
|
|||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
forwarded_impl!((), Box<str>, String::into_boxed_str);
|
forwarded_impl!((), Box<str>, String::into_boxed_str);
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
|
||||||
not(de_rc_dst),
|
|
||||||
feature = "rc",
|
|
||||||
any(feature = "std", feature = "alloc")
|
|
||||||
))]
|
|
||||||
forwarded_impl! {
|
forwarded_impl! {
|
||||||
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
||||||
///
|
///
|
||||||
@@ -1701,11 +1697,7 @@ forwarded_impl! {
|
|||||||
(T), Arc<T>, Arc::new
|
(T), Arc<T>, Arc::new
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
|
||||||
not(de_rc_dst),
|
|
||||||
feature = "rc",
|
|
||||||
any(feature = "std", feature = "alloc")
|
|
||||||
))]
|
|
||||||
forwarded_impl! {
|
forwarded_impl! {
|
||||||
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
||||||
///
|
///
|
||||||
@@ -1772,7 +1764,11 @@ where
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
|
#[cfg(all(
|
||||||
|
not(no_de_rc_dst),
|
||||||
|
feature = "rc",
|
||||||
|
any(feature = "std", feature = "alloc")
|
||||||
|
))]
|
||||||
macro_rules! box_forwarded_impl {
|
macro_rules! box_forwarded_impl {
|
||||||
(
|
(
|
||||||
$(#[doc = $doc:tt])*
|
$(#[doc = $doc:tt])*
|
||||||
@@ -1793,7 +1789,11 @@ macro_rules! box_forwarded_impl {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
|
#[cfg(all(
|
||||||
|
not(no_de_rc_dst),
|
||||||
|
feature = "rc",
|
||||||
|
any(feature = "std", feature = "alloc")
|
||||||
|
))]
|
||||||
box_forwarded_impl! {
|
box_forwarded_impl! {
|
||||||
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
||||||
///
|
///
|
||||||
@@ -1805,7 +1805,11 @@ box_forwarded_impl! {
|
|||||||
Rc
|
Rc
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
|
#[cfg(all(
|
||||||
|
not(no_de_rc_dst),
|
||||||
|
feature = "rc",
|
||||||
|
any(feature = "std", feature = "alloc")
|
||||||
|
))]
|
||||||
box_forwarded_impl! {
|
box_forwarded_impl! {
|
||||||
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
||||||
///
|
///
|
||||||
@@ -1849,7 +1853,7 @@ forwarded_impl!((T), RwLock<T>, RwLock::new);
|
|||||||
// secs: u64,
|
// secs: u64,
|
||||||
// nanos: u32,
|
// nanos: u32,
|
||||||
// }
|
// }
|
||||||
#[cfg(any(core_duration, feature = "std"))]
|
#[cfg(any(feature = "std", not(no_core_duration)))]
|
||||||
impl<'de> Deserialize<'de> for Duration {
|
impl<'de> Deserialize<'de> for Duration {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
@@ -2127,11 +2131,11 @@ impl<'de> Deserialize<'de> for SystemTime {
|
|||||||
|
|
||||||
const FIELDS: &'static [&'static str] = &["secs_since_epoch", "nanos_since_epoch"];
|
const FIELDS: &'static [&'static str] = &["secs_since_epoch", "nanos_since_epoch"];
|
||||||
let duration = try!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor));
|
let duration = try!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor));
|
||||||
#[cfg(systemtime_checked_add)]
|
#[cfg(not(no_systemtime_checked_add))]
|
||||||
let ret = UNIX_EPOCH
|
let ret = UNIX_EPOCH
|
||||||
.checked_add(duration)
|
.checked_add(duration)
|
||||||
.ok_or_else(|| D::Error::custom("overflow deserializing SystemTime"));
|
.ok_or_else(|| D::Error::custom("overflow deserializing SystemTime"));
|
||||||
#[cfg(not(systemtime_checked_add))]
|
#[cfg(no_systemtime_checked_add)]
|
||||||
let ret = Ok(UNIX_EPOCH + duration);
|
let ret = Ok(UNIX_EPOCH + duration);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
@@ -2167,7 +2171,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(range_inclusive)]
|
#[cfg(not(no_range_inclusive))]
|
||||||
impl<'de, Idx> Deserialize<'de> for RangeInclusive<Idx>
|
impl<'de, Idx> Deserialize<'de> for RangeInclusive<Idx>
|
||||||
where
|
where
|
||||||
Idx: Deserialize<'de>,
|
Idx: Deserialize<'de>,
|
||||||
@@ -2319,7 +2323,7 @@ mod range {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(any(ops_bound, collections_bound))]
|
#[cfg(any(not(no_ops_bound), all(feature = "std", not(no_collections_bound))))]
|
||||||
impl<'de, T> Deserialize<'de> for Bound<T>
|
impl<'de, T> Deserialize<'de> for Bound<T>
|
||||||
where
|
where
|
||||||
T: Deserialize<'de>,
|
T: Deserialize<'de>,
|
||||||
@@ -2430,7 +2434,7 @@ where
|
|||||||
macro_rules! nonzero_integers {
|
macro_rules! nonzero_integers {
|
||||||
( $( $T: ident, )+ ) => {
|
( $( $T: ident, )+ ) => {
|
||||||
$(
|
$(
|
||||||
#[cfg(num_nonzero)]
|
#[cfg(not(no_num_nonzero))]
|
||||||
impl<'de> Deserialize<'de> for num::$T {
|
impl<'de> Deserialize<'de> for num::$T {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
@@ -2455,7 +2459,7 @@ nonzero_integers! {
|
|||||||
NonZeroUsize,
|
NonZeroUsize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(num_nonzero_signed)]
|
#[cfg(not(no_num_nonzero_signed))]
|
||||||
nonzero_integers! {
|
nonzero_integers! {
|
||||||
NonZeroI8,
|
NonZeroI8,
|
||||||
NonZeroI16,
|
NonZeroI16,
|
||||||
@@ -2471,7 +2475,7 @@ serde_if_integer128! {
|
|||||||
NonZeroU128,
|
NonZeroU128,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(num_nonzero_signed)]
|
#[cfg(not(no_num_nonzero_signed))]
|
||||||
nonzero_integers! {
|
nonzero_integers! {
|
||||||
NonZeroI128,
|
NonZeroI128,
|
||||||
}
|
}
|
||||||
@@ -2599,7 +2603,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_atomic))]
|
#[cfg(all(feature = "std", not(no_std_atomic)))]
|
||||||
macro_rules! atomic_impl {
|
macro_rules! atomic_impl {
|
||||||
($($ty:ident)*) => {
|
($($ty:ident)*) => {
|
||||||
$(
|
$(
|
||||||
@@ -2615,14 +2619,14 @@ macro_rules! atomic_impl {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_atomic))]
|
#[cfg(all(feature = "std", not(no_std_atomic)))]
|
||||||
atomic_impl! {
|
atomic_impl! {
|
||||||
AtomicBool
|
AtomicBool
|
||||||
AtomicI8 AtomicI16 AtomicI32 AtomicIsize
|
AtomicI8 AtomicI16 AtomicI32 AtomicIsize
|
||||||
AtomicU8 AtomicU16 AtomicU32 AtomicUsize
|
AtomicU8 AtomicU16 AtomicU32 AtomicUsize
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_atomic64))]
|
#[cfg(all(feature = "std", not(no_std_atomic64)))]
|
||||||
atomic_impl! {
|
atomic_impl! {
|
||||||
AtomicI64 AtomicU64
|
AtomicI64 AtomicU64
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1215,7 +1215,7 @@ pub trait Deserializer<'de>: Sized {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Not public API.
|
// Not public API.
|
||||||
#[cfg(all(serde_derive, any(feature = "std", feature = "alloc")))]
|
#[cfg(all(not(no_serde_derive), any(feature = "std", feature = "alloc")))]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
fn __deserialize_content<V>(
|
fn __deserialize_content<V>(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
/// ($($tt:tt)*) => {};
|
/// ($($tt:tt)*) => {};
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(integer128)]
|
#[cfg(not(no_integer128))]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! serde_if_integer128 {
|
macro_rules! serde_if_integer128 {
|
||||||
($($tt:tt)*) => {
|
($($tt:tt)*) => {
|
||||||
@@ -74,7 +74,7 @@ macro_rules! serde_if_integer128 {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(integer128))]
|
#[cfg(no_integer128)]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
macro_rules! serde_if_integer128 {
|
macro_rules! serde_if_integer128 {
|
||||||
|
|||||||
+8
-8
@@ -227,27 +227,27 @@ mod lib {
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub use std::time::{SystemTime, UNIX_EPOCH};
|
pub use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
#[cfg(all(feature = "std", collections_bound))]
|
#[cfg(all(feature = "std", not(no_collections_bound), no_ops_bound))]
|
||||||
pub use std::collections::Bound;
|
pub use std::collections::Bound;
|
||||||
|
|
||||||
#[cfg(core_reverse)]
|
#[cfg(not(no_core_reverse))]
|
||||||
pub use self::core::cmp::Reverse;
|
pub use self::core::cmp::Reverse;
|
||||||
|
|
||||||
#[cfg(ops_bound)]
|
#[cfg(not(no_ops_bound))]
|
||||||
pub use self::core::ops::Bound;
|
pub use self::core::ops::Bound;
|
||||||
|
|
||||||
#[cfg(range_inclusive)]
|
#[cfg(not(no_range_inclusive))]
|
||||||
pub use self::core::ops::RangeInclusive;
|
pub use self::core::ops::RangeInclusive;
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_atomic))]
|
#[cfg(all(feature = "std", not(no_std_atomic)))]
|
||||||
pub use std::sync::atomic::{
|
pub use std::sync::atomic::{
|
||||||
AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32, AtomicU8,
|
AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32, AtomicU8,
|
||||||
AtomicUsize, Ordering,
|
AtomicUsize, Ordering,
|
||||||
};
|
};
|
||||||
#[cfg(all(feature = "std", std_atomic64))]
|
#[cfg(all(feature = "std", not(no_std_atomic64)))]
|
||||||
pub use std::sync::atomic::{AtomicI64, AtomicU64};
|
pub use std::sync::atomic::{AtomicI64, AtomicU64};
|
||||||
|
|
||||||
#[cfg(any(core_duration, feature = "std"))]
|
#[cfg(any(feature = "std", not(no_core_duration)))]
|
||||||
pub use self::core::time::Duration;
|
pub use self::core::time::Duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +296,7 @@ extern crate serde_derive;
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use serde_derive::*;
|
pub use serde_derive::*;
|
||||||
|
|
||||||
#[cfg(all(serde_derive, any(feature = "std", feature = "alloc")))]
|
#[cfg(all(not(no_serde_derive), any(feature = "std", feature = "alloc")))]
|
||||||
mod actually_private {
|
mod actually_private {
|
||||||
pub struct T;
|
pub struct T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#[cfg(serde_derive)]
|
#[cfg(not(no_serde_derive))]
|
||||||
pub mod de;
|
pub mod de;
|
||||||
#[cfg(serde_derive)]
|
#[cfg(not(no_serde_derive))]
|
||||||
pub mod ser;
|
pub mod ser;
|
||||||
|
|
||||||
pub mod size_hint;
|
pub mod size_hint;
|
||||||
@@ -22,7 +22,7 @@ pub use self::string::from_utf8_lossy;
|
|||||||
#[cfg(any(feature = "alloc", feature = "std"))]
|
#[cfg(any(feature = "alloc", feature = "std"))]
|
||||||
pub use lib::{ToString, Vec};
|
pub use lib::{ToString, Vec};
|
||||||
|
|
||||||
#[cfg(core_try_from)]
|
#[cfg(not(no_core_try_from))]
|
||||||
pub use lib::convert::TryFrom;
|
pub use lib::convert::TryFrom;
|
||||||
|
|
||||||
mod string {
|
mod string {
|
||||||
|
|||||||
+10
-10
@@ -239,7 +239,7 @@ where
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(range_inclusive)]
|
#[cfg(not(no_range_inclusive))]
|
||||||
impl<Idx> Serialize for RangeInclusive<Idx>
|
impl<Idx> Serialize for RangeInclusive<Idx>
|
||||||
where
|
where
|
||||||
Idx: Serialize,
|
Idx: Serialize,
|
||||||
@@ -258,7 +258,7 @@ where
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(any(ops_bound, collections_bound))]
|
#[cfg(any(not(no_ops_bound), all(feature = "std", not(no_collections_bound))))]
|
||||||
impl<T> Serialize for Bound<T>
|
impl<T> Serialize for Bound<T>
|
||||||
where
|
where
|
||||||
T: Serialize,
|
T: Serialize,
|
||||||
@@ -467,7 +467,7 @@ where
|
|||||||
macro_rules! nonzero_integers {
|
macro_rules! nonzero_integers {
|
||||||
( $( $T: ident, )+ ) => {
|
( $( $T: ident, )+ ) => {
|
||||||
$(
|
$(
|
||||||
#[cfg(num_nonzero)]
|
#[cfg(not(no_num_nonzero))]
|
||||||
impl Serialize for num::$T {
|
impl Serialize for num::$T {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
@@ -488,7 +488,7 @@ nonzero_integers! {
|
|||||||
NonZeroUsize,
|
NonZeroUsize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(num_nonzero_signed)]
|
#[cfg(not(no_num_nonzero_signed))]
|
||||||
nonzero_integers! {
|
nonzero_integers! {
|
||||||
NonZeroI8,
|
NonZeroI8,
|
||||||
NonZeroI16,
|
NonZeroI16,
|
||||||
@@ -504,7 +504,7 @@ serde_if_integer128! {
|
|||||||
NonZeroU128,
|
NonZeroU128,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(num_nonzero_signed)]
|
#[cfg(not(no_num_nonzero_signed))]
|
||||||
nonzero_integers! {
|
nonzero_integers! {
|
||||||
NonZeroI128,
|
NonZeroI128,
|
||||||
}
|
}
|
||||||
@@ -591,7 +591,7 @@ where
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(any(core_duration, feature = "std"))]
|
#[cfg(any(feature = "std", not(no_core_duration)))]
|
||||||
impl Serialize for Duration {
|
impl Serialize for Duration {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
@@ -890,7 +890,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(core_reverse)]
|
#[cfg(not(no_core_reverse))]
|
||||||
impl<T> Serialize for Reverse<T>
|
impl<T> Serialize for Reverse<T>
|
||||||
where
|
where
|
||||||
T: Serialize,
|
T: Serialize,
|
||||||
@@ -906,7 +906,7 @@ where
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_atomic))]
|
#[cfg(all(feature = "std", not(no_std_atomic)))]
|
||||||
macro_rules! atomic_impl {
|
macro_rules! atomic_impl {
|
||||||
($($ty:ident)*) => {
|
($($ty:ident)*) => {
|
||||||
$(
|
$(
|
||||||
@@ -923,14 +923,14 @@ macro_rules! atomic_impl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_atomic))]
|
#[cfg(all(feature = "std", not(no_std_atomic)))]
|
||||||
atomic_impl! {
|
atomic_impl! {
|
||||||
AtomicBool
|
AtomicBool
|
||||||
AtomicI8 AtomicI16 AtomicI32 AtomicIsize
|
AtomicI8 AtomicI16 AtomicI32 AtomicIsize
|
||||||
AtomicU8 AtomicU16 AtomicU32 AtomicUsize
|
AtomicU8 AtomicU16 AtomicU32 AtomicUsize
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_atomic64))]
|
#[cfg(all(feature = "std", not(no_std_atomic64)))]
|
||||||
atomic_impl! {
|
atomic_impl! {
|
||||||
AtomicI64 AtomicU64
|
AtomicI64 AtomicU64
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1280,13 +1280,13 @@ pub trait Serializer: Sized {
|
|||||||
let iter = iter.into_iter();
|
let iter = iter.into_iter();
|
||||||
let mut serializer = try!(self.serialize_seq(iterator_len_hint(&iter)));
|
let mut serializer = try!(self.serialize_seq(iterator_len_hint(&iter)));
|
||||||
|
|
||||||
#[cfg(iterator_try_fold)]
|
#[cfg(not(no_iterator_try_fold))]
|
||||||
{
|
{
|
||||||
let mut iter = iter;
|
let mut iter = iter;
|
||||||
try!(iter.try_for_each(|item| serializer.serialize_element(&item)));
|
try!(iter.try_for_each(|item| serializer.serialize_element(&item)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(iterator_try_fold))]
|
#[cfg(no_iterator_try_fold)]
|
||||||
{
|
{
|
||||||
for item in iter {
|
for item in iter {
|
||||||
try!(serializer.serialize_element(&item));
|
try!(serializer.serialize_element(&item));
|
||||||
@@ -1331,13 +1331,13 @@ pub trait Serializer: Sized {
|
|||||||
let iter = iter.into_iter();
|
let iter = iter.into_iter();
|
||||||
let mut serializer = try!(self.serialize_map(iterator_len_hint(&iter)));
|
let mut serializer = try!(self.serialize_map(iterator_len_hint(&iter)));
|
||||||
|
|
||||||
#[cfg(iterator_try_fold)]
|
#[cfg(not(no_iterator_try_fold))]
|
||||||
{
|
{
|
||||||
let mut iter = iter;
|
let mut iter = iter;
|
||||||
try!(iter.try_for_each(|(key, value)| serializer.serialize_entry(&key, &value)));
|
try!(iter.try_for_each(|(key, value)| serializer.serialize_entry(&key, &value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(iterator_try_fold))]
|
#[cfg(no_iterator_try_fold)]
|
||||||
{
|
{
|
||||||
for (key, value) in iter {
|
for (key, value) in iter {
|
||||||
try!(serializer.serialize_entry(&key, &value));
|
try!(serializer.serialize_entry(&key, &value));
|
||||||
|
|||||||
Reference in New Issue
Block a user