Skip to content

Mention that you can change the owner of data in heap to a mut variable even when the original owner wasn't mut #388

@pakhrom

Description

@pakhrom

In the third question of the second quiz in ch04-02 there's a snippet of code:

fn main() {
    let v1 = vec![1, 2, 3];
    let mut v2 = v1;
    v2.push(4);
    println!("{}", v1[0]);    
}

This snippet implies, that you can change the owner of some data in heap to a mutable variable, even though the original owner wasn't mutable, something that wasn't pointed out to be possible before this quiz.

I suggest adding a small paragraph explaining this concept before using it in the quiz.

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