-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
rename str::slice to str::slice_bytes #5793
Comments
I think it should stay as is, a str is just a transmuted [u8] with the additional invariant that it contains utf8, so it's consistent. Furthermore it would make the functions that actually allow to slice as a &[u8] more confusing. |
nominating backwards compat |
Can the function be used to cut apart unicode characters? I doubt the usefulness of such a function. Whatever the answer, |
For working with strings, you either have to use byte indices or use character iterators, otherwise you run into the issues that come with char-based indexing being O(N). |
This is working as intended. Slicing in the middle of a char is the same as slicing past the end of the array: it's a failure. We name the APIs with |
improve advice in iter_nth_zero fixes rust-lang#5783 *Please keep the line below* changelog: For iter_nth_zero, the "use .next()" replacement advice is on the last line of the code snippet, where it is vulnerable to truncation. Display that advice at the beginning instead.
str::slice
works on byte indices, so it would make more sense if the function was calledstr::slice_bytes
.The text was updated successfully, but these errors were encountered: