-
Notifications
You must be signed in to change notification settings - Fork 13.3k
std::str::StrSlice::char_at() should returns Option(char) #12882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
sorry, misoperation |
This seems to contradict #12710. Might want to think carefully about the future of strings. |
@pongad what do you mean? I don't see how this contradicts? |
@huonw Aren't we trying to remove string indexing? Or did I understand you wrong? |
Only the |
Of course my mistake! In that case, should |
I'm not sure that the API for That said, the documentation should certainly mention the possibility of failure; I'll send in a PR for that momentarily. |
@aturon @alexcrichton |
@liigo I don't think that's true -- the indexing for |
Oh, sorry. If char_at() is not indexing chars in string, maybe it should be renamed (to |
liigo, byte indices are the default for all string slice methods |
@liigo Based on the discussion, I think this issue should be closed. |
Currently,
std::str::StrSlice::char_at()
will fail if str is empty or index is out of bounds.The text was updated successfully, but these errors were encountered: