diff options
| author | Kornel <kornel@geekhood.net> | 2021-08-07 12:51:58 +0100 |
|---|---|---|
| committer | Kornel <kornel@geekhood.net> | 2021-08-07 14:48:27 +0100 |
| commit | 7dca8eb5653fb7ae5efbea2b80941997fead5ce3 (patch) | |
| tree | 7fc0a868920125abcd93a120519a16f4909bf8a8 /library/std/src | |
| parent | 215712283f044b902ef36f792e7360bb7690a65b (diff) | |
| download | rust-7dca8eb5653fb7ae5efbea2b80941997fead5ce3.tar.gz rust-7dca8eb5653fb7ae5efbea2b80941997fead5ce3.zip | |
Use assert_matches! instead of if let {} else
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/collections/hash/map/tests.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/library/std/src/collections/hash/map/tests.rs b/library/std/src/collections/hash/map/tests.rs index 18d868d49a6..d9b20aee2d2 100644 --- a/library/std/src/collections/hash/map/tests.rs +++ b/library/std/src/collections/hash/map/tests.rs @@ -1,6 +1,7 @@ use super::Entry::{Occupied, Vacant}; use super::HashMap; use super::RandomState; +use crate::assert_matches::assert_matches; use crate::cell::RefCell; use rand::{thread_rng, Rng}; use realstd::collections::TryReserveErrorKind::*; @@ -821,15 +822,17 @@ fn test_try_reserve() { const MAX_USIZE: usize = usize::MAX; - if let Err(CapacityOverflow) = empty_bytes.try_reserve(MAX_USIZE).map_err(|e| e.kind()) { - } else { - panic!("usize::MAX should trigger an overflow!"); - } - - if let Err(AllocError { .. }) = empty_bytes.try_reserve(MAX_USIZE / 8).map_err(|e| e.kind()) { - } else { - panic!("usize::MAX / 8 should trigger an OOM!") - } + assert_matches!( + empty_bytes.try_reserve(MAX_USIZE).map_err(|e| e.kind()), + Err(CapacityOverflow), + "usize::MAX should trigger an overflow!" + ); + + assert_matches!( + empty_bytes.try_reserve(MAX_USIZE / 8).map_err(|e| e.kind()), + Err(AllocError { .. }), + "usize::MAX / 8 should trigger an OOM!" + ); } #[test] |
