-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
- I have searched open and closed issues and pull requests for duplicates, using these search terms:
- string
- slice
- index
- I have checked the latest
mainbranch to see if this has already been fixed, in this file:
URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch08-02-strings.html#slicing-strings
Description of the problem:
The following sentence (in bold) sounds weird to me:
Indexing into a string is often a bad idea because it’s not clear what the return type of the string-indexing operation should be: a byte value, a character, a grapheme cluster, or a string slice. If you really need to use indices to create string slices, therefore, Rust asks you to be more specific.
Rather than indexing using [] with a single number, you can use [] with a range to create a string slice containing particular bytes:
Particularly, the word "therefore" feels out of place.
Suggested fix:
Therefore, if you really need to index a string, you will need to be more specific.