mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
246 B
14 lines
246 B
3 years ago
|
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));
|
||
|
}
|