Skip to content

Box<&mut int> allows for constructing an &int aliasing the &mut, while the &mut is still modifyable #14498

Closed
@huonw

Description

@huonw
fn main() {
    let mut a = 3i;
    let b = box &mut a;
    let c = &b;
    let d = &***c; // point to the data
    **b = 4i; // modify the data!!!

    println!("{} {}", c, d); // both 4
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions