]> git.lizzy.rs Git - rust.git/blob - src/test/ui/for-loop-while/foreach-external-iterators-hashmap.rs
Auto merge of #84589 - In-line:zircon-thread-name, r=JohnTitor
[rust.git] / src / test / ui / for-loop-while / foreach-external-iterators-hashmap.rs
1 // run-pass
2
3 use std::collections::HashMap;
4
5 pub fn main() {
6     let mut h = HashMap::new();
7     let kvs = [(1, 10), (2, 20), (3, 30)];
8     for &(k,v) in &kvs {
9         h.insert(k,v);
10     }
11     let mut x = 0;
12     let mut y = 0;
13     for (&k,&v) in &h {
14         x += k;
15         y += v;
16     }
17     assert_eq!(x, 6);
18     assert_eq!(y, 60);
19 }