-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.
Description
I’m trying to learn Rust from scratch right now, and I still have some difficulty grasping the concepts of mutability and move-semantics.
I think especially for mutability, the compiler could do a better job for suggesting fixes.
Consider the following code:
fn iter<T: Iterator<int>>(l: T) {
for e in l {
println!("{}", e);
}
}
It simply says:
error: cannot borrow immutable argument `l` as mutable
for e in l {
^
Which is kind of confusing. It should suggest to me that I add mut
to the function argument.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.