2018-12-16 21:21:47 -06:00
|
|
|
struct Node_ {
|
|
|
|
a: Box<Cycle>
|
2013-02-21 17:19:40 -06:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:21:47 -06:00
|
|
|
enum Cycle {
|
|
|
|
Node(Node_),
|
|
|
|
Empty,
|
2012-06-08 09:46:14 -05:00
|
|
|
}
|
2021-08-24 19:39:40 -05:00
|
|
|
|
2012-06-08 09:46:14 -05:00
|
|
|
fn main() {
|
2021-08-24 19:39:40 -05:00
|
|
|
let mut x: Box<_> = Box::new(Cycle::Node(Node_ {a: Box::new(Cycle::Empty)}));
|
|
|
|
|
2012-06-08 09:46:14 -05:00
|
|
|
// Create a cycle!
|
2013-03-15 14:24:24 -05:00
|
|
|
match *x {
|
2018-12-16 21:21:47 -06:00
|
|
|
Cycle::Node(ref mut y) => {
|
2013-03-15 14:24:24 -05:00
|
|
|
y.a = x; //~ ERROR cannot move out of
|
2012-06-08 09:46:14 -05:00
|
|
|
}
|
2018-12-16 21:21:47 -06:00
|
|
|
Cycle::Empty => {}
|
2012-06-08 09:46:14 -05:00
|
|
|
};
|
2012-08-07 08:04:36 -05:00
|
|
|
}
|