The first edition of the book has a section that talks about returning large structs and immediately boxing them up. This is about functions with signatures like
fn foo() -> Box<BigStruct>
and the advice there is to simply return the
BigStruct directly and let the caller decide what to do with it:
let boxed: Boxed<BigStruct> = box foo();
The book says there will be no copying done in this case. Unfortunately the book doesn't go into any detail about this pattern and it's not clear to me either when one can rely on this optimization.
It also doesn't say anything about the unboxed case, i.e., your case with code like this:
let unboxed: BigStruct = foo();