In the rustlings, in `iterators2.rs', I need to capitalize the first letter of a word.
This is the code that I have
pub fn capitalize_first(input: &str) -> String {
let mut c = input.chars();
return match c.next() {
None => String::new(),
Some(first) => first.to_uppercase(),
};
}
The issue I get is
--> exercises/standard_library_types/iterators2.rs:13:24
|
11 | return match c.next() {
| ____________-
12 | | None => String::new(),
| | ------------- this is found to be of type `String`
13 | | Some(first) => first.to_uppercase(),
| | ^^^^^^^^^^^^^^^^^^^^- help: try using a conversion method: `.to_string()`
| | |
| | expected struct `String`, found struct `ToUppercase`
14 | | };
| |_____- `match` arms have incompatible types
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
Why does char.to_uppercase() return struct ToUppercase
and not a capitalized char?