Skip to content

Rust book: explain in strings chapter how to get a substring reference #25853

Closed
@nliberg

Description

@nliberg

In strings.md it could be useful to explain the &s[1..2] and &s[2..] syntax for getting a substring slice.

Looking for a way to get a substring reference one is currently faced with the str API documentation which is quite a lot to digest and if one manages to find the unstable slice_chars(...) it says "Use slicing syntax if you want to use byte indices rather than codepoint indices", but what "slicing syntax" means will probably not be clear to someone who is new to Rust and not yet familiar with the Index trait.

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