2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2015-10-06 11:48:55 +00:00
|
|
|
// Example taken from RFC 1238 text
|
|
|
|
|
2015-10-06 14:51:20 +00:00
|
|
|
// https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md
|
|
|
|
// #examples-of-code-that-must-continue-to-work
|
2015-10-06 11:48:55 +00:00
|
|
|
|
|
|
|
use std::cell::Cell;
|
|
|
|
|
2023-12-27 22:11:58 +00:00
|
|
|
struct Concrete<'a>(#[allow(dead_code)] u32, Cell<Option<&'a Concrete<'a>>>);
|
2015-10-06 11:48:55 +00:00
|
|
|
|
|
|
|
struct Foo<T> { data: Vec<T> }
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut foo = Foo { data: Vec::new() };
|
|
|
|
foo.data.push(Concrete(0, Cell::new(None)));
|
|
|
|
foo.data.push(Concrete(0, Cell::new(None)));
|
|
|
|
|
|
|
|
foo.data[0].1.set(Some(&foo.data[1]));
|
|
|
|
foo.data[1].1.set(Some(&foo.data[0]));
|
|
|
|
}
|