mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Use matches macro in libcore and libstd
This commit is contained in:
@@ -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(_))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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(_))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user