Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

不安全操作

不安全操作是指那些可能违反 Rust 静态语义的内存安全保证的操作。

以下语言级特性不能在 Rust 的安全子集中使用:

  • 访问 union 的字段,除非是为了赋值。
  • 调用不安全的函数。

  1. 在 2024 版之前,extern 块允许不带 unsafe 声明。