Appearance
Day 14 - 智能指针
Box
rust
let b = Box::new(5);
println!("{}", b);
// 递归类型
enum List {
Cons(i32, Box<List>),
Nil,
}Rc(引用计数)
rust
use std::rc::Rc;
let data = Rc::new(vec![1, 2, 3]);
let a = Rc::clone(&data);
let b = Rc::clone(&data);RefCell
rust
use std::cell::RefCell;
let data = RefCell::new(vec![1, 2, 3]);
data.borrow_mut().push(4);📅 学习进度
| Day | 主题 | 状态 |
|---|---|---|
| 01-13 | 基础 | ✅ |
| 14 | 智能指针 | ✅ |
| 15 | Unsafe Rust | ⬜ |
