You can use concatenation to avoid a character by character copy.
... for (i, c) in input.chars().enumerate() { let upper = c.to_uppercase().to_string(); let subresult = input[..i].to_string() + &upper + &input[i+upper.len()..]; result.push(subresult); } ...
I don't know the first thing about Rust, so this is probably not optimal either.
Playgrund link here
Nice!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You can use concatenation to avoid a character by character copy.
I don't know the first thing about Rust, so this is probably not optimal either.
Playgrund link here
Nice!