Why is capitalizing the first letter of a string so convoluted in Rust?
I'd like to capitalize the first letter of a &str . It's a simple problem and I hope for a simple solution. Intuition tells me to do something like this: let mut s = "foobar"; s[0] = s[0].to_uppercase(); But &str s can't be indexed like this. The only way I've been able to do it seems overly convoluted. I convert the &str to an iterator, convert the iterator to a vector, upper case the first item in the vector, which creates an iterator, which I index into, creating an Option , which I unwrap to give me the upper-cased first letter. Then I convert the vector into an iterator, which I convert