mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-05-05 13:08:05 +08:00
21 lines
329 B
Rust
21 lines
329 B
Rust
|
use crate::List::{Cons, Nil};
|
||
|
use std::cell::RefCell;
|
||
|
use std::rc::Rc;
|
||
|
|
||
|
#[derive(Debug)]
|
||
|
enum List {
|
||
|
Cons(i32, RefCell<Rc<List>>),
|
||
|
Nil,
|
||
|
}
|
||
|
|
||
|
impl List {
|
||
|
fn tail(&self) -> Option<&RefCell<Rc<List>>> {
|
||
|
match self {
|
||
|
Cons(_, item) => Some(item),
|
||
|
Nil => None,
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn main() {}
|