Skip to content

Non-uint array indexing #18878

Closed
Closed
@Yamakaky

Description

@Yamakaky

Hi

Currently, rust doesn't seem to accept non uint types as index for an array. As an example, this code doesn't compile :

let array = [1, 2, 3, 4];
let index: u16 = 1;
let item = array[index];

I have to do

let item = array[index as uint];

Couldn't rustc automate this conversion ?

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