Use matches macro in libcore and libstd

This commit is contained in:
Igor Aleksanov
2020-01-07 10:35:16 +03:00
parent aa0769b92e
commit f720469fd0
12 changed files with 29 additions and 118 deletions
+2 -8
View File
@@ -227,10 +227,7 @@ pub fn set_port(&mut self, new_port: u16) {
/// ```
#[stable(feature = "sockaddr_checker", since = "1.16.0")]
pub fn is_ipv4(&self) -> bool {
match *self {
SocketAddr::V4(_) => true,
SocketAddr::V6(_) => false,
}
matches!(*self, SocketAddr::V4(_))
}
/// Returns [`true`] if the [IP address] in this `SocketAddr` is an
@@ -252,10 +249,7 @@ pub fn is_ipv4(&self) -> bool {
/// ```
#[stable(feature = "sockaddr_checker", since = "1.16.0")]
pub fn is_ipv6(&self) -> bool {
match *self {
SocketAddr::V4(_) => false,
SocketAddr::V6(_) => true,
}
matches!(*self, SocketAddr::V6(_))
}
}
+2 -8
View File
@@ -281,10 +281,7 @@ pub fn is_documentation(&self) -> bool {
/// ```
#[stable(feature = "ipaddr_checker", since = "1.16.0")]
pub fn is_ipv4(&self) -> bool {
match self {
IpAddr::V4(_) => true,
IpAddr::V6(_) => false,
}
matches!(self, IpAddr::V4(_))
}
/// Returns [`true`] if this address is an [IPv6 address], and [`false`] otherwise.
@@ -303,10 +300,7 @@ pub fn is_ipv4(&self) -> bool {
/// ```
#[stable(feature = "ipaddr_checker", since = "1.16.0")]
pub fn is_ipv6(&self) -> bool {
match self {
IpAddr::V4(_) => false,
IpAddr::V6(_) => true,
}
matches!(self, IpAddr::V6(_))
}
}