Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Non-lexical scope won't help with that. Remember that Rust does not allow mutable aliasing, so this code can never be allowed:

    let mut arr = [1, 2];
    let a = &mut arr[0];
    let b = &mut arr[0];
This code could be allowed:

    let mut arr = [1, 2];
    let a = &mut arr[0];
    let b = &mut arr[1];
And it gets Hard once variable indexes are involved. And since the whole point of using arrays is to get variable indexing, the Rust developers choose to only implement reborrowing for structs and tuples.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: