Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array indexing may not move #4

Open
lcnr opened this issue Sep 4, 2023 · 0 comments
Open

array indexing may not move #4

lcnr opened this issue Sep 4, 2023 · 0 comments

Comments

@lcnr
Copy link
Owner

lcnr commented Sep 4, 2023

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant