about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-01-09 00:22:10 +0100
committerGitHub <noreply@github.com>2020-01-09 00:22:10 +0100
commit5ea69781f46a556b3d6f7e8e52d5641d61d12131 (patch)
treea5024d981e459032f7ca7c9c59485fd783ef0405 /src/libstd/sync
parent11f0013378f8a7ec7a2ca3e09afd78e1397273e7 (diff)
parentf720469fd0c4dff6d92e2f778ea2f252f76dcc2e (diff)
downloadrust-5ea69781f46a556b3d6f7e8e52d5641d61d12131.tar.gz
rust-5ea69781f46a556b3d6f7e8e52d5641d61d12131.zip
Rollup merge of #67966 - popzxc:core-std-matches, r=Centril
Use matches macro in libcore and libstd

This PR replaces matches like

```rust
match var {
    value => true,
    _ => false,
}
```

with use of `matches!` macro.

r? @Centril
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/barrier.rs5
-rw-r--r--src/libstd/sync/mpsc/oneshot.rs7
2 files changed, 2 insertions, 10 deletions
diff --git a/src/libstd/sync/barrier.rs b/src/libstd/sync/barrier.rs
index eddbdff257a..01314370ce3 100644
--- a/src/libstd/sync/barrier.rs
+++ b/src/libstd/sync/barrier.rs
@@ -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();
 
diff --git a/src/libstd/sync/mpsc/oneshot.rs b/src/libstd/sync/mpsc/oneshot.rs
index bbe77e7d0fb..5b41525e06a 100644
--- a/src/libstd/sync/mpsc/oneshot.rs
+++ b/src/libstd/sync/mpsc/oneshot.rs
@@ -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>> {