summaryrefslogtreecommitdiffstats
path: root/tests/ui/for-loop-while/foreach-external-iterators-hashmap.rs
blob: 9f2ca05cdb61c60f436c6d4bd31183fba3267668 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// run-pass

use std::collections::HashMap;

pub fn main() {
    let mut h = HashMap::new();
    let kvs = [(1, 10), (2, 20), (3, 30)];
    for &(k,v) in &kvs {
        h.insert(k,v);
    }
    let mut x = 0;
    let mut y = 0;
    for (&k,&v) in &h {
        x += k;
        y += v;
    }
    assert_eq!(x, 6);
    assert_eq!(y, 60);
}