2012-10-15 14:00:32 -05:00
|
|
|
struct list<T> {
|
|
|
|
element: &self/T,
|
|
|
|
mut next: Option<@list<T>>
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> list<T>{
|
|
|
|
fn addEnd(&self, element: &self/T) {
|
|
|
|
let newList = list {
|
|
|
|
element: element,
|
|
|
|
next: option::None
|
|
|
|
};
|
|
|
|
|
2012-10-15 19:18:45 -05:00
|
|
|
self.next = Some(@(move newList));
|
2012-10-15 14:00:32 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let s = @"str";
|
2012-10-15 19:18:45 -05:00
|
|
|
let ls = list {
|
2012-10-15 14:00:32 -05:00
|
|
|
element: &s,
|
|
|
|
next: option::None
|
|
|
|
};
|
|
|
|
io::println(*ls.element);
|
|
|
|
}
|