From a7254c333b8ae177f4b5c44907225af8b35910ad Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Thu, 10 May 2018 00:37:55 +0200 Subject: [PATCH] Remove useless macro. --- src/wire/icmp.rs | 76 ++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 58 deletions(-) diff --git a/src/wire/icmp.rs b/src/wire/icmp.rs index 2961a92c8..684ea5e29 100644 --- a/src/wire/icmp.rs +++ b/src/wire/icmp.rs @@ -3,62 +3,22 @@ use super::icmpv4; #[cfg(feature = "proto-ipv6")] use super::icmpv6; -macro_rules! v4v6 { - ( $class:ident ) => { - /// icmpv4::$class or icmpv6::$class - #[derive(Clone, PartialEq, Debug)] - pub enum $class { - #[cfg(feature = "proto-ipv4")] - Ipv4(icmpv4::$class), - #[cfg(feature = "proto-ipv6")] - Ipv6(icmpv6::$class), - } - - #[cfg(feature = "proto-ipv4")] - impl From for $class { - fn from(s: icmpv4::$class) -> Self { - $class::Ipv4(s) - } - } - #[cfg(feature = "proto-ipv6")] - impl From for $class { - fn from(s: icmpv6::$class) -> Self { - $class::Ipv6(s) - } - } - }; - ( $class:ident < $typearg:tt > ) => { - /// icmpv4::$class or icmpv6::$class - #[derive(Clone, PartialEq, Debug)] - pub enum $class<$typearg> { - #[cfg(feature = "proto-ipv4")] - Ipv4(icmpv4::$class<$typearg>), - #[cfg(feature = "proto-ipv6")] - Ipv6(icmpv6::$class<$typearg>), - } - #[cfg(feature = "proto-ipv4")] - impl<$typearg> From> for $class<$typearg> { - fn from(s: icmpv4::$class<$typearg>) -> Self { - $class::Ipv4(s) - } - } - #[cfg(feature = "proto-ipv6")] - impl<$typearg> From> for $class<$typearg> { - fn from(s: icmpv6::$class<$typearg>) -> Self { - $class::Ipv6(s) - } - } - }; - ( $class:ident < $typearg:tt : $typebound:path > ) => { - /// icmpv4::$class or icmpv6::$class - #[derive(Clone, PartialEq, Debug)] - pub enum $class<$typearg : $typebound> { - #[cfg(feature = "proto-ipv4")] - Ipv4(icmpv4::$class<$typearg>), - #[cfg(feature = "proto-ipv6")] - IPv6(icmpv6::$class<$typearg>), - } - }; +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum Repr<'a> { + #[cfg(feature = "proto-ipv4")] + Ipv4(icmpv4::Repr<'a>), + #[cfg(feature = "proto-ipv6")] + Ipv6(icmpv6::Repr<'a>), +} +#[cfg(feature = "proto-ipv4")] +impl<'a> From> for Repr<'a> { + fn from(s: icmpv4::Repr<'a>) -> Self { + Repr::Ipv4(s) + } +} +#[cfg(feature = "proto-ipv6")] +impl<'a> From> for Repr<'a> { + fn from(s: icmpv6::Repr<'a>) -> Self { + Repr::Ipv6(s) + } } - -v4v6!(Repr<'a>);