2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(dead_code)]
|
2018-08-31 08:02:01 -05:00
|
|
|
#![allow(non_snake_case)]
|
|
|
|
#![allow(non_camel_case_types)]
|
2013-10-23 03:49:18 -05:00
|
|
|
|
2013-12-31 17:46:27 -06:00
|
|
|
use std::cell::RefCell;
|
|
|
|
|
2013-07-18 19:12:46 -05:00
|
|
|
static S: &'static str = "str";
|
|
|
|
|
|
|
|
struct list<T> {
|
|
|
|
element: T,
|
2014-10-02 00:10:09 -05:00
|
|
|
next: Option<Box<RefCell<list<T>>>>
|
2012-10-15 14:00:32 -05:00
|
|
|
}
|
|
|
|
|
2013-07-18 19:12:46 -05:00
|
|
|
impl<T:'static> list<T> {
|
|
|
|
pub fn addEnd(&mut self, element: T) {
|
2012-10-15 14:00:32 -05:00
|
|
|
let newList = list {
|
|
|
|
element: element,
|
2013-05-24 21:35:29 -05:00
|
|
|
next: None
|
2012-10-15 14:00:32 -05:00
|
|
|
};
|
|
|
|
|
2022-07-06 21:36:10 -05:00
|
|
|
self.next = Some(Box::new(RefCell::new(newList)));
|
2012-10-15 14:00:32 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-01 21:43:17 -06:00
|
|
|
pub fn main() {
|
2012-10-15 19:18:45 -05:00
|
|
|
let ls = list {
|
2013-07-18 19:12:46 -05:00
|
|
|
element: S,
|
2013-05-24 21:35:29 -05:00
|
|
|
next: None
|
2012-10-15 14:00:32 -05:00
|
|
|
};
|
2014-01-09 04:06:55 -06:00
|
|
|
println!("{}", ls.element);
|
2012-10-15 14:00:32 -05:00
|
|
|
}
|