Use matches macro in libcore and libstd
This commit is contained in:
parent
aa0769b92e
commit
f720469fd0
12 changed files with 29 additions and 118 deletions
|
|
@ -227,10 +227,7 @@ impl SocketAddr {
|
|||
/// ```
|
||||
#[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 @@ impl SocketAddr {
|
|||
/// ```
|
||||
#[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 @@ impl IpAddr {
|
|||
/// ```
|
||||
#[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 @@ impl IpAddr {
|
|||
/// ```
|
||||
#[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(_))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -224,18 +224,12 @@ impl<'a> Prefix<'a> {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn is_verbatim(&self) -> bool {
|
||||
use self::Prefix::*;
|
||||
match *self {
|
||||
Verbatim(_) | VerbatimDisk(_) | VerbatimUNC(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*self, Verbatim(_) | VerbatimDisk(_) | VerbatimUNC(..))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_drive(&self) -> bool {
|
||||
match *self {
|
||||
Prefix::Disk(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*self, Prefix::Disk(_))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
|
|
@ -199,10 +199,7 @@ mod tests {
|
|||
|
||||
// At this point, all spawned threads should be blocked,
|
||||
// so we shouldn't get anything from the port
|
||||
assert!(match rx.try_recv() {
|
||||
Err(TryRecvError::Empty) => true,
|
||||
_ => false,
|
||||
});
|
||||
assert!(matches!(rx.try_recv(), Err(TryRecvError::Empty)));
|
||||
|
||||
let mut leader_found = barrier.wait().is_leader();
|
||||
|
||||
|
|
|
|||
|
|
@ -118,12 +118,7 @@ impl<T> Packet<T> {
|
|||
// Just tests whether this channel has been sent on or not, this is only
|
||||
// safe to use from the sender.
|
||||
pub fn sent(&self) -> bool {
|
||||
unsafe {
|
||||
match *self.upgrade.get() {
|
||||
NothingSent => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
unsafe { !matches!(*self.upgrade.get(), NothingSent) }
|
||||
}
|
||||
|
||||
pub fn recv(&self, deadline: Option<Instant>) -> Result<T, Failure<T>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue