mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-14 08:11:02 +00:00
Deduplicate atomic_impl macro implementations
This commit is contained in:
+2
-18
@@ -2660,27 +2660,11 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
|
#[cfg(all(feature = "std", not(no_std_atomic)))]
|
||||||
macro_rules! atomic_impl {
|
macro_rules! atomic_impl {
|
||||||
($($ty:ident $size:expr)*) => {
|
($($ty:ident $size:expr)*) => {
|
||||||
$(
|
$(
|
||||||
impl<'de> Deserialize<'de> for $ty {
|
#[cfg(any(no_target_has_atomic, target_has_atomic = $size))]
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
Deserialize::deserialize(deserializer).map(Self::new)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)*
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
|
|
||||||
macro_rules! atomic_impl {
|
|
||||||
($($ty:ident $size:expr)*) => {
|
|
||||||
$(
|
|
||||||
#[cfg(target_has_atomic = $size)]
|
|
||||||
impl<'de> Deserialize<'de> for $ty {
|
impl<'de> Deserialize<'de> for $ty {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
|
|||||||
+2
-19
@@ -945,28 +945,11 @@ where
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
|
#[cfg(all(feature = "std", not(no_std_atomic)))]
|
||||||
macro_rules! atomic_impl {
|
macro_rules! atomic_impl {
|
||||||
($($ty:ident $size:expr)*) => {
|
($($ty:ident $size:expr)*) => {
|
||||||
$(
|
$(
|
||||||
impl Serialize for $ty {
|
#[cfg(any(no_target_has_atomic, target_has_atomic = $size))]
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: Serializer,
|
|
||||||
{
|
|
||||||
// Matches the atomic ordering used in libcore for the Debug impl
|
|
||||||
self.load(Ordering::Relaxed).serialize(serializer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)*
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
|
|
||||||
macro_rules! atomic_impl {
|
|
||||||
($($ty:ident $size:expr)*) => {
|
|
||||||
$(
|
|
||||||
#[cfg(target_has_atomic = $size)]
|
|
||||||
impl Serialize for $ty {
|
impl Serialize for $ty {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
|
|||||||
Reference in New Issue
Block a user