Skip to content

Commit b0ee22a

Browse files
committed
---
yaml --- r: 24126 b: refs/heads/master c: a8406e3 h: refs/heads/master v: v3
1 parent 54483ab commit b0ee22a

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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 91fe3fcbef43c68943b57b0cfaf637c84d39926c
2+
refs/heads/master: a8406e3d00ca791317f85d369e6157e4b5a2cf90
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/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)