2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2014-05-29 19:03:06 -07:00
|
|
|
use std::collections::HashMap;
|
2013-07-30 18:46:40 -07:00
|
|
|
|
2013-09-25 00:43:37 -07:00
|
|
|
pub fn main() {
|
2013-07-30 18:46:40 -07:00
|
|
|
let mut h = HashMap::new();
|
2015-01-25 22:05:03 +01:00
|
|
|
let kvs = [(1, 10), (2, 20), (3, 30)];
|
2015-01-31 12:20:46 -05:00
|
|
|
for &(k,v) in &kvs {
|
2013-07-30 18:46:40 -07:00
|
|
|
h.insert(k,v);
|
|
|
|
}
|
2015-01-25 22:05:03 +01:00
|
|
|
let mut x = 0;
|
|
|
|
let mut y = 0;
|
2015-01-31 12:20:46 -05:00
|
|
|
for (&k,&v) in &h {
|
2013-07-30 18:46:40 -07:00
|
|
|
x += k;
|
|
|
|
y += v;
|
|
|
|
}
|
|
|
|
assert_eq!(x, 6);
|
|
|
|
assert_eq!(y, 60);
|
2013-09-25 00:43:37 -07:00
|
|
|
}
|