summaryrefslogtreecommitdiffstats
path: root/src/doc/book/listings/ch15-smart-pointers/listing-15-18/src/main.rs
blob: 602f7de40de263e1d5c532fe12d7975c75521ae2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
enum List {
    Cons(i32, Rc<List>),
    Nil,
}

use crate::List::{Cons, Nil};
use std::rc::Rc;

fn main() {
    let a = Rc::new(Cons(5, Rc::new(Cons(10, Rc::new(Nil)))));
    let b = Cons(3, Rc::clone(&a));
    let c = Cons(4, Rc::clone(&a));
}