Code
fn main() {
let input = "lowercase";
let uppercase: String = input.chars().map(|c| c.to_ascii_uppercase());
}
Current output
error[E0308]: mismatched types
--> $DIR/string-from-char-iterator-without-collect.rs:10:29
|
LL | let uppercase: String = input.chars().map(|c| c.to_ascii_uppercase());
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `Map<Chars<'_>, {closure@...}>`
| |
| expected due to this
|
= note: expected struct `String`
found struct `Map<Chars<'_>, {closure@$DIR/string-from-char-iterator-without-collect.rs:10:47: 10:50}>`
Desired output
error[E0308]: mismatched types
--> $DIR/string-from-char-iterator-without-collect.rs:10:29
|
LL | let uppercase: String = input.chars().map(|c| c.to_ascii_uppercase());
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `Map<Chars<'_>, {closure@...}>`
| |
| expected due to this
|
= note: expected struct `String`
found struct `Map<Chars<'_>, {closure@$DIR/string-from-char-iterator-without-collect.rs:10:47: 10:50}>`
help: you can collect the `Iterator<Item = char>` into a `String`
|
LL | let uppercase: String = input.chars().map(|c| c.to_ascii_uppercase()).collect();
| ++++++++++
Rationale and extra context
No response
Other cases
Rust Version
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
No response
Other cases
Rust Version
Anything else?
No response