]> git.proxmox.com Git - rustc.git/blob - src/doc/book/listings/ch15-smart-pointers/listing-15-25/src/main.rs
New upstream version 1.43.0+dfsg1
[rustc.git] / src / doc / book / listings / ch15-smart-pointers / listing-15-25 / src / main.rs
1 use crate::List::{Cons, Nil};
2 use std::cell::RefCell;
3 use std::rc::Rc;
4
5 #[derive(Debug)]
6 enum List {
7 Cons(i32, RefCell<Rc<List>>),
8 Nil,
9 }
10
11 impl List {
12 fn tail(&self) -> Option<&RefCell<Rc<List>>> {
13 match self {
14 Cons(_, item) => Some(item),
15 Nil => None,
16 }
17 }
18 }
19
20 fn main() {}