Skip to content

Mutable indexing is strange. #17597

Closed
Closed
@HeroesGrave

Description

@HeroesGrave

Mutably indexing a Vec (and probably lots of other collections) is weird.
On one hand, you can dereference a mutable pointer:

*vec.get_mut(index) = value;

Which is ugly and inconsistent with immutable indexing (vec[index])

With the new slicing syntax you can do this:

vec[mut][index] = value;

Which is arguably nicer. But wouldn't something like:

vec[mut index] = value;

Be even better and more consistent?

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