Skip to content

array indexing may not move #4

Open
@lcnr

Description

@lcnr
fn fails_1(x: [String; 3], y: usize) {
    let q: String = x[y];
    //~^ ERROR cannot move out of type `[String; 3]`, a non-copy array
}

fn works_1(x: [String; 3], y: usize) {
    let _: String = x[y];
}

fn fails_2(x: [String; 3]) {
    let q: String = x[1];
    //~^ ERROR cannot move out of type `[String; 3]`, a non-copy array
}

fn works_2(x: [String; 3]) {
    let [_, q, _] = x;
    let [a, _, b] = x;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions