Merge pull request #1589 from Flaise/nonzeroi
Add support for NonZeroI* types
This commit is contained in:
commit
ce75418e40
@ -69,11 +69,12 @@ fn main() {
|
||||
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#library-stabilizations
|
||||
if minor >= 34 {
|
||||
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
|
||||
// would use #[cfg(target_has_atomic = "...")] but it is not stable yet.
|
||||
|
@ -2404,7 +2404,6 @@ macro_rules! nonzero_integers {
|
||||
}
|
||||
|
||||
nonzero_integers! {
|
||||
// Not including signed NonZeroI* since they might be removed
|
||||
NonZeroU8,
|
||||
NonZeroU16,
|
||||
NonZeroU32,
|
||||
@ -2412,12 +2411,26 @@ nonzero_integers! {
|
||||
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
|
||||
// additional `#[cfg]`
|
||||
serde_if_integer128! {
|
||||
nonzero_integers! {
|
||||
NonZeroU128,
|
||||
}
|
||||
|
||||
#[cfg(num_nonzero_signed)]
|
||||
nonzero_integers! {
|
||||
NonZeroI128,
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -481,7 +481,6 @@ macro_rules! nonzero_integers {
|
||||
}
|
||||
|
||||
nonzero_integers! {
|
||||
// Not including signed NonZeroI* since they might be removed
|
||||
NonZeroU8,
|
||||
NonZeroU16,
|
||||
NonZeroU32,
|
||||
@ -489,12 +488,26 @@ nonzero_integers! {
|
||||
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
|
||||
// additional `#[cfg]`
|
||||
serde_if_integer128! {
|
||||
nonzero_integers! {
|
||||
NonZeroU128,
|
||||
}
|
||||
|
||||
#[cfg(num_nonzero_signed)]
|
||||
nonzero_integers! {
|
||||
NonZeroI128,
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Serialize for Cell<T>
|
||||
|
Loading…
Reference in New Issue
Block a user