]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
0bf4aa26 | 2 | #![allow(dead_code)] |
b7449926 XL |
3 | #![allow(non_snake_case)] |
4 | #![allow(non_camel_case_types)] | |
1a4d82fc JJ |
5 | #![feature(box_syntax)] |
6 | ||
7 | use std::cell::RefCell; | |
8 | ||
9 | static S: &'static str = "str"; | |
10 | ||
11 | struct list<T> { | |
12 | element: T, | |
13 | next: Option<Box<RefCell<list<T>>>> | |
223e47cc LB |
14 | } |
15 | ||
1a4d82fc JJ |
16 | impl<T:'static> list<T> { |
17 | pub fn addEnd(&mut self, element: T) { | |
223e47cc LB |
18 | let newList = list { |
19 | element: element, | |
970d7e83 | 20 | next: None |
223e47cc LB |
21 | }; |
22 | ||
1a4d82fc | 23 | self.next = Some(box RefCell::new(newList)); |
223e47cc LB |
24 | } |
25 | } | |
26 | ||
27 | pub fn main() { | |
223e47cc | 28 | let ls = list { |
1a4d82fc | 29 | element: S, |
970d7e83 | 30 | next: None |
223e47cc | 31 | }; |
1a4d82fc | 32 | println!("{}", ls.element); |
223e47cc | 33 | } |