]> git.lizzy.rs Git - rust.git/blob - src/test/ui/suggestions/suggest-mut-method-for-loop-hashmap.fixed
Auto merge of #103600 - compiler-errors:early-binder-nits, r=spastorino
[rust.git] / src / test / ui / suggestions / suggest-mut-method-for-loop-hashmap.fixed
1 // run-rustfix
2 // https://github.com/rust-lang/rust/issues/82081
3
4 use std::collections::HashMap;
5
6 struct Test {
7     v: u32,
8 }
9
10 fn main() {
11     let mut map = HashMap::new();
12     map.insert("a", Test { v: 0 });
13
14     for (_k, mut v) in map.iter_mut() {
15         //~^ HELP use mutable method
16         //~| NOTE this iterator yields `&` references
17         v.v += 1;
18         //~^ ERROR cannot assign to `v.v`
19         //~| NOTE `v` is a `&` reference
20     }
21 }