Skip to content

Commit 1f00648

Browse files
committed
---
yaml --- r: 41676 b: refs/heads/master c: 0c05a6c h: refs/heads/master v: v3
1 parent a73f14a commit 1f00648

File tree

3 files changed

+11
-53
lines changed

3 files changed

+11
-53
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f0fa67d6bf22bbca80c1c148de05c7990a2ed04b
2+
refs/heads/master: 0c05a6c092ac80904b6c3054688f23337b126f3c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/doc/tutorial.md

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -863,34 +863,11 @@ allocating memory and indirecting through a pointer. But for big structs, or
863863
those with mutable fields, it can be useful to have a single copy on
864864
the stack or on the heap, and refer to that through a pointer.
865865

866-
Whenever memory is allocated on the heap, the program needs a strategy to
867-
dispose of the memory when no longer needed. Most languages, such as Java or
868-
Python, use *garbage collection* for this, a strategy in which the program
869-
periodically searches for allocations that are no longer reachable in order
870-
to dispose of them. Other languages, such as C, use *manual memory
871-
management*, which relies on the programmer to specify when memory should be
872-
reclaimed.
873-
874-
Rust is in a different position. It differs from the garbage-collected
875-
environments in that allows the programmer to choose the disposal
876-
strategy on an object-by-object basis. Not only does this have benefits for
877-
performance, but we will later see that this model has benefits for
878-
concurrency as well, by making it possible for the Rust compiler to detect
879-
data races at compile time. Rust also differs from the manually managed
880-
languages in that it is *safe*—it uses a [pointer lifetime
881-
analysis][borrow] to ensure that manual memory management cannot cause memory
882-
errors at runtime.
883-
884-
[borrow]: tutorial-borrowed-ptr.html
885-
886-
The cornerstone of Rust's memory management is the concept of a *smart
887-
pointer*—a pointer type that indicates the lifetime of the object it points
888-
to. This solution is familiar to C++ programmers; Rust differs from C++,
889-
however, in that a small set of smart pointers are built into the language.
890-
The safe pointer types are `@T`, for *managed* boxes allocated on the *local
891-
heap*, `~T`, for *uniquely-owned* boxes allocated on the *exchange
892-
heap*, and `&T`, for *borrowed* pointers, which may point to any memory, and
893-
whose lifetimes are governed by the call stack.
866+
Rust supports several types of pointers. The safe pointer types are
867+
`@T`, for managed boxes allocated on the local heap, `~T`, for
868+
uniquely-owned boxes allocated on the exchange heap, and `&T`, for
869+
borrowed pointers, which may point to any memory, and whose lifetimes
870+
are governed by the call stack.
894871

895872
All pointer types can be dereferenced with the `*` unary operator.
896873

@@ -942,17 +919,7 @@ node2.next = SomeNode(node3);
942919
node3.prev = SomeNode(node2);
943920
~~~
944921

945-
Managed boxes never cross task boundaries. This has several benefits for
946-
performance:
947-
948-
* The Rust garbage collector does not need to stop multiple threads in order
949-
to collect garbage.
950-
951-
* You can separate your application into "real-time" tasks that do not use
952-
the garbage collector and "non-real-time" tasks that do, and the real-time
953-
tasks will not be interrupted by the non-real-time tasks.
954-
955-
C++ programmers will recognize `@T` as similar to `std::shared_ptr<T>`.
922+
Managed boxes never cross task boundaries.
956923

957924
> ***Note:*** Currently, the Rust compiler generates code to reclaim
958925
> managed boxes through reference counting and a cycle collector, but
@@ -989,19 +956,10 @@ let z = *x + *y;
989956
assert z == 20;
990957
~~~~
991958

992-
When they do not contain any managed boxes, owned boxes can be sent
993-
to other tasks. The sending task will give up ownership of the box
959+
Owned boxes, when they do not contain any managed boxes, can be sent
960+
to other tasks. The sending task will give up ownership of the box,
994961
and won't be able to access it afterwards. The receiving task will
995-
become the sole owner of the box. This prevents *data races*—errors
996-
that could otherwise result from multiple tasks working on the same
997-
data without synchronization.
998-
999-
When an owned pointer goes out of scope or is overwritten, the object
1000-
it points to is immediately freed. Effective use of owned boxes can
1001-
therefore be an efficient alternative to garbage collection.
1002-
1003-
C++ programmers will recognize `~T` as similar to `std::unique_ptr<T>`
1004-
(or `std::auto_ptr<T>` in C++03 and below).
962+
become the sole owner of the box.
1005963

1006964
## Borrowed pointers
1007965

trunk/src/librustdoc/prune_private_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn fold_mod(
4949
let doc = fold::default_any_fold_mod(fold, doc);
5050

5151
doc::ModDoc_({
52-
items: doc.items.filter(|ItemTag| {
52+
items: doc.items.filtered(|ItemTag| {
5353
is_visible(fold.ctxt, ItemTag.item())
5454
}),
5555
.. *doc

0 commit comments

Comments
 (0)