diff options
| author | bors <bors@rust-lang.org> | 2014-09-02 07:01:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-09-02 07:01:07 +0000 |
| commit | 0ff7bac2d8b365926e0b336c9c2a5b1c8aa72a36 (patch) | |
| tree | 38be86522f2df00b3776593ce9933b4f6674187f | |
| parent | 0bdac78da87605f6f7f6e7924872617226b19c85 (diff) | |
| parent | d32bfe8c2b30af0ade09e23c0ec060c50edd7f47 (diff) | |
| download | rust-0ff7bac2d8b365926e0b336c9c2a5b1c8aa72a36.tar.gz rust-0ff7bac2d8b365926e0b336c9c2a5b1c8aa72a36.zip | |
auto merge of #16924 : steveklabnik/rust/manual_pointer_fix, r=pcwalton
This was brought up in IRC: https://botbot.me/mozilla/rust/2014-08-30/?msg=20733803&page=26
| -rw-r--r-- | src/doc/rust.md | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/doc/rust.md b/src/doc/rust.md index ba5a01f899f..5fcdbcc85a6 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -3668,32 +3668,17 @@ let a: List<int> = Cons(7, box Cons(13, box Nil)); All pointers in Rust are explicit first-class values. They can be copied, stored into data structures, and returned from functions. -There are four varieties of pointer in Rust: - -* Owning pointers (`Box`) - : These point to owned heap allocations (or "boxes") in the shared, inter-task heap. - Each owned box has a single owning pointer; pointer and pointee retain a 1:1 relationship at all times. - Owning pointers are written `Box<content>`, - for example `Box<int>` means an owning pointer to an owned box containing an integer. - Copying an owned box is a "deep" operation: - it involves allocating a new owned box and copying the contents of the old box into the new box. - Releasing an owning pointer immediately releases its corresponding owned box. +There are two varieties of pointer in Rust: * References (`&`) : These point to memory _owned by some other value_. - References arise by (automatic) conversion from owning pointers, managed pointers, - or by applying the borrowing operator `&` to some other value, - including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries). - A borrow expression is written `&content`. - - A reference type is written `&'f type` for some lifetime-variable `f`, - or just `&type` when the lifetime can be elided; - for example `&int` means a reference to an integer. + A reference type is written `&type` for some lifetime-variable `f`, + or just `&'a type` when you need an explicit lifetime. Copying a reference is a "shallow" operation: it involves only copying the pointer itself. Releasing a reference typically has no effect on the value it points to, - with the exception of temporary values, - which are released when the last reference to them is released. + with the exception of temporary values, which are released when the last + reference to them is released. * Raw pointers (`*`) : Raw pointers are pointers without safety or liveness guarantees. @@ -3706,6 +3691,9 @@ There are four varieties of pointer in Rust: they exist to support interoperability with foreign code, and writing performance-critical or low-level functions. +The standard library contains addtional 'smart pointer' types beyond references +and raw pointers. + ### Function types The function type constructor `fn` forms new function types. |
