Skip to content

Chapter 8.2: sentence sounds weird #4537

@sam113101

Description

@sam113101

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions