Given the following code:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=005f59d63a84412a73cfe88146c11f39
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`.
Given the following code:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=005f59d63a84412a73cfe88146c11f39
The current output is:
Ideally the output should look like: