summaryrefslogblamecommitdiff
path: root/meap/meap-code/ch2/ch2-needle-in-haystack.rs
blob: 45de1f046266650b1fc63d11b632ab0be6bb6e14 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                                    
fn main() {
  let needle = 42;
  let haystack = [1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862]; // <1>
    
  for reference in haystack.iter() { // <2>
    let item = *reference; // <3>
    if item == needle {
      println!("{}", item);
    }

    // if reference == &needle { // <4>
    //   println!("{}", reference);
    // }
  }
}