Skip to content

Commit

Permalink
Relocate cfg attrs out of parse_ip_impl and parse_socket_impl
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 6, 2024
1 parent 07e614b commit 26fb134
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions serde/src/de/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,7 @@ map_impl! {

////////////////////////////////////////////////////////////////////////////////

#[cfg(any(feature = "std", not(no_core_net)))]
macro_rules! parse_ip_impl {
(
$(#[$attr:meta])*
Expand Down Expand Up @@ -1735,16 +1736,17 @@ impl<'de> Deserialize<'de> for net::IpAddr {
}
}

#[cfg(any(feature = "std", not(no_core_net)))]
parse_ip_impl! {
#[cfg(any(feature = "std", not(no_core_net)))]
net::Ipv4Addr, "IPv4 address", 4
}

#[cfg(any(feature = "std", not(no_core_net)))]
parse_ip_impl! {
#[cfg(any(feature = "std", not(no_core_net)))]
net::Ipv6Addr, "IPv6 address", 16
}

#[cfg(any(feature = "std", not(no_core_net)))]
macro_rules! parse_socket_impl {
(
$(#[$attr:meta])*
Expand Down Expand Up @@ -1786,14 +1788,14 @@ impl<'de> Deserialize<'de> for net::SocketAddr {
}
}

#[cfg(any(feature = "std", not(no_core_net)))]
parse_socket_impl! {
#[cfg(any(feature = "std", not(no_core_net)))]
net::SocketAddrV4, "IPv4 socket address",
|(ip, port)| net::SocketAddrV4::new(ip, port),
}

#[cfg(any(feature = "std", not(no_core_net)))]
parse_socket_impl! {
#[cfg(any(feature = "std", not(no_core_net)))]
net::SocketAddrV6, "IPv6 socket address",
|(ip, port)| net::SocketAddrV6::new(ip, port, 0, 0),
}
Expand Down

0 comments on commit 26fb134

Please sign in to comment.