]> git.lizzy.rs Git - rust.git/commit
Guide: motivate Box and Rc pointers with need, uses, benefits, and examples.
authorJohn Kleint <jk@hinge.co>
Wed, 22 Oct 2014 03:30:09 +0000 (23:30 -0400)
committerJohn Kleint <jk@hinge.co>
Mon, 27 Oct 2014 03:41:51 +0000 (23:41 -0400)
commitd257b376084ce18ae351e1f89989e36433515d24
treeb3ba06d972b39e1c32ed39f7e3b35cb1f5c28a26
parentf037452447f5f46deb26e1c483fe88fb51a19198
Guide: motivate Box and Rc pointers with need, uses, benefits, and examples.

Explain that Rust has different pointer types because there is a
tradeoff between flexibility and efficiency. Motivate boxes as
fixed-size containers of variable-sized objects. Clarify that Box and Rc
are pointer types that you deref with * just like references. Stick to
explaining the semantics and avoid implementation details.  Scope isn't
the most accurate framework to think about deallocation (since you
return boxes and otherwise move values out of scopes); it's more "when
the value is done being used," i.e., lifetime. Provide a connection
between Rust's pointer types by locating them on a flexibiltiy /
performance scale. Explain the compiler can't statically analyze
lifetimes with multiple owners; hence the need for (runtime) reference
counting.
src/doc/guide.md