Skip to content

Error in example #139

@liudasdev

Description

@liudasdev

"// a is not valid here" comment is incorrect or rather confusing. It's is not clear whether comment "// a is not valid here" is meant to be in the next line, or the taking ownership is not working as described in the example.

Adding test of variable availability and value invalidates assumption of ownership takeover and drop. Maybe taking ownership does not mean drop. If drop is not intended, than it's not clear what "valid" and "ownership" means in this context and what the example is trying to showcase.

#[test]
fun test_owner() {
    let a = owner();
    take_ownership(a);
    // a is not valid here

    // let's check
    assert!(a == 10) // -> ALL GOOD
}

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