Skip to content

src/doc/complement-lang-faq.md mentions str indexing, which was removed #19344

Closed
@SimonSapin

Description

@SimonSapin

Scanning a str for ASCII-range codepoints can still be done safely octet-at-a-time, with each indexing operation pulling out a u8 costing only O(1) and producing a value that can be cast and compared to an ASCII-range char.

Indexing on &str used to return u8 but is now an error: strings do not support indexing at all.

This paragraph will need to be rephrased. Maybe suggest using .as_bytes(), where the index in the resulting &[u8] of an ASCII-range byte can safely be used e.g. to slice the original str.

CC @steveklabnik

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