SHARE
TWEET

Untitled

a guest Jan 21st, 2020 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::vec;
  2.  
  3. #[derive(Debug)]
  4. struct Nazvy {
  5.     cislo: i32,
  6.     nazov: String
  7.    
  8. }
  9.  
  10. fn main() {
  11.     let ciselka: Vec<Nazvy> = vec![
  12.         Nazvy { cislo: 1, nazov: "Peter".to_string() },
  13.         Nazvy { cislo: 3, nazov: "Boris".to_string() },
  14.         Nazvy { cislo: 4, nazov: "M├írio".to_string() },
  15.         Nazvy { cislo: 5, nazov: "Jakub".to_string() },
  16.         Nazvy { cislo: 6, nazov: "Jozef".to_string() }
  17.     ];
  18.  
  19.     let a: Vec<&String> = ciselka
  20.         .iter()
  21.         .filter(|&x| x.cislo % 2 == 0)
  22.         .map(|x| &x.nazov)
  23.         .collect();
  24.  
  25.     println!("{:?}", a);
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top