Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::collections::HashSet;
- #[derive(Debug)]
- struct Z<'a> {
- name: String,
- hashset: &'a HashSet<&'a str>,
- }
- fn main() {
- let mut books = HashSet::new();
- books.insert("A Dance With Dragons");
- books.insert("To Kill a Mockingbird");
- books.insert("The Odyssey");
- books.insert("The Great Gatsby");
- let mut movies = HashSet::new();
- movies.insert("A Dance With Dragons");
- movies.insert("To Kill a Mockingbird");
- movies.insert("The Matrix");
- let z = Z{name: "Movies".to_string(), hashset: &movies};
- let union = &books ^ &movies;
- println!("{:?}", union);
- let hashsets = vec![&books, &movies];
- println!("{:?}", hashsets);
- println!("{:?}", z);
- }
Add Comment
Please, Sign In to add comment