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