Skip to content

Commit f0eed1e

Browse files
committed
Make use of match ergonomics in ip methods
1 parent 2f1f43f commit f0eed1e

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

src/libstd/net/ip.rs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ impl IpAddr {
160160
/// ```
161161
#[stable(feature = "ip_shared", since = "1.12.0")]
162162
pub fn is_unspecified(&self) -> bool {
163-
match *self {
164-
IpAddr::V4(ref a) => a.is_unspecified(),
165-
IpAddr::V6(ref a) => a.is_unspecified(),
163+
match self {
164+
IpAddr::V4(ip) => ip.is_unspecified(),
165+
IpAddr::V6(ip) => ip.is_unspecified(),
166166
}
167167
}
168168

@@ -185,9 +185,9 @@ impl IpAddr {
185185
/// ```
186186
#[stable(feature = "ip_shared", since = "1.12.0")]
187187
pub fn is_loopback(&self) -> bool {
188-
match *self {
189-
IpAddr::V4(ref a) => a.is_loopback(),
190-
IpAddr::V6(ref a) => a.is_loopback(),
188+
match self {
189+
IpAddr::V4(ip) => ip.is_loopback(),
190+
IpAddr::V6(ip) => ip.is_loopback(),
191191
}
192192
}
193193

@@ -214,9 +214,9 @@ impl IpAddr {
214214
/// }
215215
/// ```
216216
pub fn is_global(&self) -> bool {
217-
match *self {
218-
IpAddr::V4(ref a) => a.is_global(),
219-
IpAddr::V6(ref a) => a.is_global(),
217+
match self {
218+
IpAddr::V4(ip) => ip.is_global(),
219+
IpAddr::V6(ip) => ip.is_global(),
220220
}
221221
}
222222

@@ -239,9 +239,9 @@ impl IpAddr {
239239
/// ```
240240
#[stable(feature = "ip_shared", since = "1.12.0")]
241241
pub fn is_multicast(&self) -> bool {
242-
match *self {
243-
IpAddr::V4(ref a) => a.is_multicast(),
244-
IpAddr::V6(ref a) => a.is_multicast(),
242+
match self {
243+
IpAddr::V4(ip) => ip.is_multicast(),
244+
IpAddr::V6(ip) => ip.is_multicast(),
245245
}
246246
}
247247

@@ -268,9 +268,9 @@ impl IpAddr {
268268
/// }
269269
/// ```
270270
pub fn is_documentation(&self) -> bool {
271-
match *self {
272-
IpAddr::V4(ref a) => a.is_documentation(),
273-
IpAddr::V6(ref a) => a.is_documentation(),
271+
match self {
272+
IpAddr::V4(ip) => ip.is_documentation(),
273+
IpAddr::V6(ip) => ip.is_documentation(),
274274
}
275275
}
276276

@@ -293,7 +293,7 @@ impl IpAddr {
293293
/// ```
294294
#[stable(feature = "ipaddr_checker", since = "1.16.0")]
295295
pub fn is_ipv4(&self) -> bool {
296-
match *self {
296+
match self {
297297
IpAddr::V4(_) => true,
298298
IpAddr::V6(_) => false,
299299
}
@@ -318,7 +318,7 @@ impl IpAddr {
318318
/// ```
319319
#[stable(feature = "ipaddr_checker", since = "1.16.0")]
320320
pub fn is_ipv6(&self) -> bool {
321-
match *self {
321+
match self {
322322
IpAddr::V4(_) => false,
323323
IpAddr::V6(_) => true,
324324
}
@@ -669,9 +669,9 @@ impl Ipv4Addr {
669669
#[stable(feature = "ip_addr", since = "1.7.0")]
670670
impl fmt::Display for IpAddr {
671671
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
672-
match *self {
673-
IpAddr::V4(ref a) => a.fmt(fmt),
674-
IpAddr::V6(ref a) => a.fmt(fmt),
672+
match self {
673+
IpAddr::V4(ip) => ip.fmt(fmt),
674+
IpAddr::V6(ip) => ip.fmt(fmt),
675675
}
676676
}
677677
}
@@ -720,8 +720,8 @@ impl PartialEq for Ipv4Addr {
720720
#[stable(feature = "ip_cmp", since = "1.16.0")]
721721
impl PartialEq<Ipv4Addr> for IpAddr {
722722
fn eq(&self, other: &Ipv4Addr) -> bool {
723-
match *self {
724-
IpAddr::V4(ref v4) => v4 == other,
723+
match self {
724+
IpAddr::V4(v4) => v4 == other,
725725
IpAddr::V6(_) => false,
726726
}
727727
}
@@ -730,8 +730,8 @@ impl PartialEq<Ipv4Addr> for IpAddr {
730730
#[stable(feature = "ip_cmp", since = "1.16.0")]
731731
impl PartialEq<IpAddr> for Ipv4Addr {
732732
fn eq(&self, other: &IpAddr) -> bool {
733-
match *other {
734-
IpAddr::V4(ref v4) => self == v4,
733+
match other {
734+
IpAddr::V4(v4) => self == v4,
735735
IpAddr::V6(_) => false,
736736
}
737737
}
@@ -758,8 +758,8 @@ impl PartialOrd for Ipv4Addr {
758758
#[stable(feature = "ip_cmp", since = "1.16.0")]
759759
impl PartialOrd<Ipv4Addr> for IpAddr {
760760
fn partial_cmp(&self, other: &Ipv4Addr) -> Option<Ordering> {
761-
match *self {
762-
IpAddr::V4(ref v4) => v4.partial_cmp(other),
761+
match self {
762+
IpAddr::V4(v4) => v4.partial_cmp(other),
763763
IpAddr::V6(_) => Some(Ordering::Greater),
764764
}
765765
}
@@ -768,8 +768,8 @@ impl PartialOrd<Ipv4Addr> for IpAddr {
768768
#[stable(feature = "ip_cmp", since = "1.16.0")]
769769
impl PartialOrd<IpAddr> for Ipv4Addr {
770770
fn partial_cmp(&self, other: &IpAddr) -> Option<Ordering> {
771-
match *other {
772-
IpAddr::V4(ref v4) => self.partial_cmp(v4),
771+
match other {
772+
IpAddr::V4(v4) => self.partial_cmp(v4),
773773
IpAddr::V6(_) => Some(Ordering::Less),
774774
}
775775
}
@@ -1338,19 +1338,19 @@ impl PartialEq for Ipv6Addr {
13381338
#[stable(feature = "ip_cmp", since = "1.16.0")]
13391339
impl PartialEq<IpAddr> for Ipv6Addr {
13401340
fn eq(&self, other: &IpAddr) -> bool {
1341-
match *other {
1341+
match other {
13421342
IpAddr::V4(_) => false,
1343-
IpAddr::V6(ref v6) => self == v6,
1343+
IpAddr::V6(v6) => self == v6,
13441344
}
13451345
}
13461346
}
13471347

13481348
#[stable(feature = "ip_cmp", since = "1.16.0")]
13491349
impl PartialEq<Ipv6Addr> for IpAddr {
13501350
fn eq(&self, other: &Ipv6Addr) -> bool {
1351-
match *self {
1351+
match self {
13521352
IpAddr::V4(_) => false,
1353-
IpAddr::V6(ref v6) => v6 == other,
1353+
IpAddr::V6(v6) => v6 == other,
13541354
}
13551355
}
13561356
}
@@ -1375,19 +1375,19 @@ impl PartialOrd for Ipv6Addr {
13751375
#[stable(feature = "ip_cmp", since = "1.16.0")]
13761376
impl PartialOrd<Ipv6Addr> for IpAddr {
13771377
fn partial_cmp(&self, other: &Ipv6Addr) -> Option<Ordering> {
1378-
match *self {
1378+
match self {
13791379
IpAddr::V4(_) => Some(Ordering::Less),
1380-
IpAddr::V6(ref v6) => v6.partial_cmp(other),
1380+
IpAddr::V6(v6) => v6.partial_cmp(other),
13811381
}
13821382
}
13831383
}
13841384

13851385
#[stable(feature = "ip_cmp", since = "1.16.0")]
13861386
impl PartialOrd<IpAddr> for Ipv6Addr {
13871387
fn partial_cmp(&self, other: &IpAddr) -> Option<Ordering> {
1388-
match *other {
1388+
match other {
13891389
IpAddr::V4(_) => Some(Ordering::Greater),
1390-
IpAddr::V6(ref v6) => self.partial_cmp(v6),
1390+
IpAddr::V6(v6) => self.partial_cmp(v6),
13911391
}
13921392
}
13931393
}

0 commit comments

Comments
 (0)