mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 05:31:02 +00:00
Merge pull request #1589 from Flaise/nonzeroi
Add support for NonZeroI* types
This commit is contained in:
+2
-1
@@ -69,11 +69,12 @@ fn main() {
|
|||||||
println!("cargo:rustc-cfg=num_nonzero");
|
println!("cargo:rustc-cfg=num_nonzero");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TryFrom and Atomic types stabilized in Rust 1.34:
|
// TryFrom, Atomic types, and non-zero signed integers 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=core_try_from");
|
||||||
|
println!("cargo:rustc-cfg=num_nonzero_signed");
|
||||||
|
|
||||||
// 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.
|
||||||
|
|||||||
+14
-1
@@ -2404,7 +2404,6 @@ macro_rules! nonzero_integers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nonzero_integers! {
|
nonzero_integers! {
|
||||||
// Not including signed NonZeroI* since they might be removed
|
|
||||||
NonZeroU8,
|
NonZeroU8,
|
||||||
NonZeroU16,
|
NonZeroU16,
|
||||||
NonZeroU32,
|
NonZeroU32,
|
||||||
@@ -2412,12 +2411,26 @@ nonzero_integers! {
|
|||||||
NonZeroUsize,
|
NonZeroUsize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(num_nonzero_signed)]
|
||||||
|
nonzero_integers! {
|
||||||
|
NonZeroI8,
|
||||||
|
NonZeroI16,
|
||||||
|
NonZeroI32,
|
||||||
|
NonZeroI64,
|
||||||
|
NonZeroIsize,
|
||||||
|
}
|
||||||
|
|
||||||
// Currently 128-bit integers do not work on Emscripten targets so we need an
|
// Currently 128-bit integers do not work on Emscripten targets so we need an
|
||||||
// additional `#[cfg]`
|
// additional `#[cfg]`
|
||||||
serde_if_integer128! {
|
serde_if_integer128! {
|
||||||
nonzero_integers! {
|
nonzero_integers! {
|
||||||
NonZeroU128,
|
NonZeroU128,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(num_nonzero_signed)]
|
||||||
|
nonzero_integers! {
|
||||||
|
NonZeroI128,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
+14
-1
@@ -481,7 +481,6 @@ macro_rules! nonzero_integers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nonzero_integers! {
|
nonzero_integers! {
|
||||||
// Not including signed NonZeroI* since they might be removed
|
|
||||||
NonZeroU8,
|
NonZeroU8,
|
||||||
NonZeroU16,
|
NonZeroU16,
|
||||||
NonZeroU32,
|
NonZeroU32,
|
||||||
@@ -489,12 +488,26 @@ nonzero_integers! {
|
|||||||
NonZeroUsize,
|
NonZeroUsize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(num_nonzero_signed)]
|
||||||
|
nonzero_integers! {
|
||||||
|
NonZeroI8,
|
||||||
|
NonZeroI16,
|
||||||
|
NonZeroI32,
|
||||||
|
NonZeroI64,
|
||||||
|
NonZeroIsize,
|
||||||
|
}
|
||||||
|
|
||||||
// Currently 128-bit integers do not work on Emscripten targets so we need an
|
// Currently 128-bit integers do not work on Emscripten targets so we need an
|
||||||
// additional `#[cfg]`
|
// additional `#[cfg]`
|
||||||
serde_if_integer128! {
|
serde_if_integer128! {
|
||||||
nonzero_integers! {
|
nonzero_integers! {
|
||||||
NonZeroU128,
|
NonZeroU128,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(num_nonzero_signed)]
|
||||||
|
nonzero_integers! {
|
||||||
|
NonZeroI128,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Serialize for Cell<T>
|
impl<T> Serialize for Cell<T>
|
||||||
|
|||||||
Reference in New Issue
Block a user