@@ -1052,6 +1052,34 @@ let y = x; // Copy of a pointer to the same box
1052
1052
// then the allocation will be freed.
1053
1053
~~~~
1054
1054
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
+
1055
1083
Managed boxes never cross task boundaries.
1056
1084
1057
1085
> *** Note:*** managed boxes are currently reclaimed through reference
@@ -1060,7 +1088,7 @@ Managed boxes never cross task boundaries.
1060
1088
1061
1089
## Owned boxes
1062
1090
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
1064
1092
slot and thus two owned boxes may not refer to the same memory. All
1065
1093
owned boxes across all tasks are allocated on a single _ exchange
1066
1094
heap_ , where their uniquely owned nature allows them to be passed
0 commit comments