Skip to content

Commit

Permalink
docs: rust - unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan4yin committed Sep 17, 2024
1 parent 1e6ac20 commit 1a03901
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pl/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,24 @@ Rust 的线程实现使用 1:1 模型,即一个 Rust 线程对应一个 OS 线
中使用 `Box<T>`/`Rc<T>` 等数据结构,编译器会直接报错,告诉你它们未实现 `Send`/`Sync` trait,即不是线
程安全的。

## 宏 - macro
## unsafe

待续
Unsafe 的 5 项特殊能力:

## unsafe
- Dereference a raw pointer
- Call an unsafe function or method
- Access or modify a mutable static variable
- Implement an unsafe trait
- Access fields of a union

> 注意:unsafe 代码块仍然会被借用检查器与其他 Rust 安全策略检查,unsafe 只是使你可以使用上述 5 项特
> 殊能力,但 unsafe 代码仍旧需要遵守 Rust 的安全规则。
## 宏 - macro

待续


## async/await

- [async-book](https://rust-lang.github.io/async-book/)

0 comments on commit 1a03901

Please sign in to comment.