summaryrefslogblamecommitdiff
path: root/meap/meap-code/ch2/ch2-intro.rs
blob: 5162fee40b96b835f0227363eaa301935d27952f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

















                                                                                                       
fn main() {
  let start_at = 3;
  let stop_at = 10;
  let mut items = vec![];

  for (i,x) in (start_at..stop_at).enumerate() {
    let y = i as i64 * x;
    items.push(y);
  }

  println!("{:?}", items);

//let multiples_of_10 = items.iter().filter(|&y| y % 10 == 0).map(|&y| y.clone()).collect::<Vec<_>>();
//let multiples_of_10: Vec<_> = items.iter().filter(|&y| y % 10 == 0).map(|&y| y.clone()).collect();
  let multiples_of_10: Vec<_> = items.into_iter().filter(|y| y % 10 == 0).collect();
  println!("{:?}", multiples_of_10);

}