about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/collections/hash/map/tests.rs21
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]