Skip to content

Ownership Guide: Borrowing example doesn't work with previously introduced main function #19924

Closed
@lgrahl

Description

@lgrahl

In the ownership guide is an example for borrowing that doesn't work with the previously introduced main function. I guess this is because cross-borrowing is not allowed anymore?

fn main() {
    let x = box 5i;
    add_one(x);
    println!("{}", x);
}
fn add_one(num: &mut int) {
    *num += 1;
}

See: https://github.com/rust-lang/rust/blob/master/src/doc/guide-ownership.md#borrowing

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