Guest User

Untitled

a guest
May 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. use std::collections::HashSet;
  2.  
  3. #[derive(Debug)]
  4. struct Z<'a> {
  5. name: String,
  6. hashset: &'a HashSet<&'a str>,
  7. }
  8.  
  9. fn main() {
  10. let mut books = HashSet::new();
  11.  
  12. books.insert("A Dance With Dragons");
  13. books.insert("To Kill a Mockingbird");
  14. books.insert("The Odyssey");
  15. books.insert("The Great Gatsby");
  16.  
  17. let mut movies = HashSet::new();
  18.  
  19. movies.insert("A Dance With Dragons");
  20. movies.insert("To Kill a Mockingbird");
  21. movies.insert("The Matrix");
  22.  
  23. let z = Z{name: "Movies".to_string(), hashset: &movies};
  24.  
  25. let union = &books ^ &movies;
  26. println!("{:?}", union);
  27.  
  28. let hashsets = vec![&books, &movies];
  29. println!("{:?}", hashsets);
  30.  
  31. println!("{:?}", z);
  32. }
Add Comment
Please, Sign In to add comment