Skip to content

Commit 3b14e8c

Browse files
committed
---
yaml --- r: 30726 b: refs/heads/incoming c: a8406e3 h: refs/heads/master v: v3
1 parent beaaf8c commit 3b14e8c

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 91fe3fcbef43c68943b57b0cfaf637c84d39926c
9+
refs/heads/incoming: a8406e3d00ca791317f85d369e6157e4b5a2cf90
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/doc/tutorial.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,34 @@ let y = x; // Copy of a pointer to the same box
10521052
// then the allocation will be freed.
10531053
~~~~
10541054

1055+
Any type that contains managed boxes or other managed types is
1056+
considered _managed_. Managed types are the only types that can
1057+
construct cyclic data structures in Rust, such as doubly-linked lists.
1058+
1059+
~~~
1060+
// A linked list node
1061+
struct Node {
1062+
mut next: MaybeNode,
1063+
mut prev: MaybeNode,
1064+
payload: int
1065+
}
1066+
1067+
enum MaybeNode {
1068+
SomeNode(@Node),
1069+
NoNode
1070+
}
1071+
1072+
let node1 = @Node { next: NoNode, prev: NoNode, payload: 1 };
1073+
let node2 = @Node { next: NoNode, prev: NoNode, payload: 2 };
1074+
let node3 = @Node { next: NoNode, prev: NoNode, payload: 3 };
1075+
1076+
// Link the three list nodes together
1077+
node1.next = SomeNode(node2);
1078+
node2.prev = SomeNode(node1);
1079+
node2.next = SomeNode(node3);
1080+
node3.prev = SomeNode(node2);
1081+
~~~
1082+
10551083
Managed boxes never cross task boundaries.
10561084

10571085
> ***Note:*** managed boxes are currently reclaimed through reference
@@ -1060,7 +1088,7 @@ Managed boxes never cross task boundaries.
10601088
10611089
## Owned boxes
10621090

1063-
In contrast to maneged boxes, owned boxes have a single owning memory
1091+
In contrast to managed boxes, owned boxes have a single owning memory
10641092
slot and thus two owned boxes may not refer to the same memory. All
10651093
owned boxes across all tasks are allocated on a single _exchange
10661094
heap_, where their uniquely owned nature allows them to be passed

0 commit comments

Comments
 (0)