Open
Description
Given the following code:
fn main() {
let greeting = "Hello, World!";
let mut output = 0;
for c in greeting.chars() {
output += c;
}
println!("The values of the characters in \"{greeting}\" sum to {output}");
}
The current output is:
error[E0277]: cannot add-assign `char` to `{integer}`
--> src/main.rs:5:10
|
5 | output += c;
| ^^ no implementation for `{integer} += char`
|
= help: the trait `AddAssign<char>` is not implemented for `{integer}`
For more information about this error, try `rustc --explain E0277`.
Ideally the output should look like:
error[E0277]: cannot add-assign `char` to `{integer}`
--> src/main.rs:5:10
|
5 | output += c;
| ^^ no implementation for `{integer} += char`
|
= help: the trait `AddAssign<char>` is not implemented for `{integer}`. You may have meant to use `as u32` or `to_digit` on the `char`.
For more information about this error, try `rustc --explain E0277`.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.