mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-14 09:21:01 +00:00
Centralize atomic imports
This commit is contained in:
+12
-15
@@ -2546,12 +2546,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
|
||||||
use std::sync::atomic;
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
macro_rules! atomic_impl {
|
macro_rules! atomic_impl {
|
||||||
($ty:path, $primitive:ident) => {
|
($ty:ident, $primitive:ident) => {
|
||||||
impl<'de> Deserialize<'de> for $ty {
|
impl<'de> Deserialize<'de> for $ty {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
@@ -2566,34 +2563,34 @@ macro_rules! atomic_impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicBool, bool);
|
atomic_impl!(AtomicBool, bool);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicI8, i8);
|
atomic_impl!(AtomicI8, i8);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicI16, i16);
|
atomic_impl!(AtomicI16, i16);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicI32, i32);
|
atomic_impl!(AtomicI32, i32);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicI64, i64);
|
atomic_impl!(AtomicI64, i64);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicIsize, isize);
|
atomic_impl!(AtomicIsize, isize);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicU8, u8);
|
atomic_impl!(AtomicU8, u8);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicU16, u16);
|
atomic_impl!(AtomicU16, u16);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicU32, u32);
|
atomic_impl!(AtomicU32, u32);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicU64, u64);
|
atomic_impl!(AtomicU64, u64);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicUsize, usize);
|
atomic_impl!(AtomicUsize, usize);
|
||||||
|
|||||||
@@ -212,6 +212,12 @@ mod lib {
|
|||||||
#[cfg(range_inclusive)]
|
#[cfg(range_inclusive)]
|
||||||
pub use self::core::ops::RangeInclusive;
|
pub use self::core::ops::RangeInclusive;
|
||||||
|
|
||||||
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
|
pub use std::sync::atomic::{
|
||||||
|
AtomicBool, AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, AtomicU16, AtomicU32,
|
||||||
|
AtomicU64, AtomicU8, AtomicUsize, Ordering,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(any(core_duration, feature = "std"))]
|
#[cfg(any(core_duration, feature = "std"))]
|
||||||
pub use self::core::time::Duration;
|
pub use self::core::time::Duration;
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-16
@@ -842,53 +842,50 @@ where
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
|
||||||
use std::sync::atomic;
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
macro_rules! atomic_impl {
|
macro_rules! atomic_impl {
|
||||||
($ty:path, $method:ident $($cast:tt)*) => {
|
($ty:ident, $method:ident $($cast:tt)*) => {
|
||||||
impl Serialize for $ty {
|
impl Serialize for $ty {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
serializer.$method(self.load(atomic::Ordering::SeqCst) $($cast)*)
|
serializer.$method(self.load(Ordering::SeqCst) $($cast)*)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicBool, serialize_bool);
|
atomic_impl!(AtomicBool, serialize_bool);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicI8, serialize_i8);
|
atomic_impl!(AtomicI8, serialize_i8);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicI16, serialize_i16);
|
atomic_impl!(AtomicI16, serialize_i16);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicI32, serialize_i32);
|
atomic_impl!(AtomicI32, serialize_i32);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicI64, serialize_i64);
|
atomic_impl!(AtomicI64, serialize_i64);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicIsize, serialize_i64 as i64);
|
atomic_impl!(AtomicIsize, serialize_i64 as i64);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicU8, serialize_u8);
|
atomic_impl!(AtomicU8, serialize_u8);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicU16, serialize_u16);
|
atomic_impl!(AtomicU16, serialize_u16);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicU32, serialize_u32);
|
atomic_impl!(AtomicU32, serialize_u32);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicU64, serialize_u64);
|
atomic_impl!(AtomicU64, serialize_u64);
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(atomic::AtomicUsize, serialize_u64 as u64);
|
atomic_impl!(AtomicUsize, serialize_u64 as u64);
|
||||||
|
|||||||
Reference in New Issue
Block a user