How can I make this compile:
struct S {
s:String
}
fn main() {
let mut v:Vec<S>;
let cmp = "asdf";
v.iter_mut().find(|&&x| x == cmp);
// ^^^
// What to write here when using find on a iter_mut (and why?)
}
Error message:
--> src/main.rs:8:25
|
8 | v.iter_mut().find(|&&x| x == cmp);
| ^-
| ||
| |expected due to this
| types differ in mutability
| help: you can probably remove the explicit borrow: `x`
|
= note: expected mutable reference `&mut S`
found reference `&_`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `asdf` due to previous error