one of the recent changes with box is that it does placement new. So
generally, this is bad:

fn foo(x: int) -> Box<int> {
   box (x + 1)
}

let y = foo(5);

Because it forces your caller to use a Box. Instead...

fn foo(x: int) -> int {
   x + 1
}

Because then your caller can choose:

let y = foo(5);

for a copy, and

let y = box foo(5);

for a boxed value. Or, in the future....

let y = box(GC) foo(5);

At least, that's my current understanding.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to