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