]> git.proxmox.com Git - rustc.git/blobdiff - library/std/src/collections/hash/set/tests.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / library / std / src / collections / hash / set / tests.rs
index 40f8467fd93fddf18907d1a9d55440164a9a522f..6a625e6243c2157f4416502f28b3240b56480e3b 100644 (file)
@@ -484,3 +484,15 @@ fn test_drain_filter_pred_panic_leak() {
     assert_eq!(DROPS.load(Ordering::SeqCst), 3);
     assert_eq!(set.len(), 0);
 }
+
+#[test]
+fn from_array() {
+    let set = HashSet::from([1, 2, 3, 4]);
+    let unordered_duplicates = HashSet::from([4, 1, 4, 3, 2]);
+    assert_eq!(set, unordered_duplicates);
+
+    // This next line must infer the hasher type parameter.
+    // If you make a change that causes this line to no longer infer,
+    // that's a problem!
+    let _must_not_require_type_annotation = HashSet::from([1, 2]);
+}