MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / iter

Function iter

publication/code/chapter06/hashmap.rs:242–259  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

240 }
241
242 fn iter() {
243 let mut hmap = HashMap::new(11);
244 hmap.insert(2,"dog");
245 hmap.insert(3,"tiger");
246 hmap.insert(10,"cat");
247
248 for item in hmap.iter() {
249 println!("val: {item}");
250 }
251
252 for item in hmap.iter_mut() {
253 *item = "fish";
254 }
255
256 for item in hmap.iter() {
257 println!("val: {item}");
258 }
259 }
260}

Callers 1

mainFunction · 0.70

Calls 3

insertMethod · 0.45
iterMethod · 0.45
iter_mutMethod · 0.45

Tested by

no test coverage detected