mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-04-30 18:28:15 +08:00
14 lines
246 B
Rust
Executable File
14 lines
246 B
Rust
Executable File
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));
|
|
}
|