Suggest to use .chars().nth(x) or .as_bytes() when trying to index str #57055
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
It’s a pain point for beginners that they cannot index
String
s orstr
s. It would make it much less frustrating if they got an helpful error message.Right now, we get this error message:
But it’s not clear what we should do, and the error message doesn’t guide the user toward the solution. It would be better if there was an error message as the following instead:
The text was updated successfully, but these errors were encountered: