Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::collections::HashSet;
- fn main() {
- let mut s1 = HashSet::new();
- s1.insert(String::from("a"));
- s1.insert(String::from("b"));
- s1.insert(String::from("c"));
- let mut s2 = HashSet::new();
- s2.insert(String::from("d"));
- s2.insert(String::from("b"));
- s2.insert(String::from("c"));
- assert!(s2.contains("d"));
- let mut union = s1.union(&s2);
- // Compile error
- assert!(union.collect::<HashSet<_>>().contains("d"));
- // Alternative assertions
- assert!(union.position(|i| i == "d").is_some());
- }
Add Comment
Please, Sign In to add comment