We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
struct Foo { pub v: Vec<String> } fn main() { let f = Foo { v: Vec::new() }; f.v.push("cat".to_string()); }
The above code gives this compile error:
<anon>:8:5: 8:8 error: cannot borrow immutable field `f.v` as mutable <anon>:8 f.v.push("cat".to_string()); ^~~
From my perspective, this implies that the field somehow needs to be marked as mutable, when in fact the user error is that the struct is immutable.
I believe the error message could be improved by saying something like cannot borrow field vof immutable structf as mutable. #18150 is "related".
cannot borrow field
of immutable struct
as mutable