<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>5 游戏规则 on 编程那些事儿</title><link>https://before80.github.io/prgms/Rust/comprehensiveRust/unsafe/rules-of-the-game/</link><description>Recent content in 5 游戏规则 on 编程那些事儿</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Tue, 11 Aug 2026 23:57:44 +0800</lastBuildDate><atom:link href="https://before80.github.io/prgms/Rust/comprehensiveRust/unsafe/rules-of-the-game/index.xml" rel="self" type="application/rss+xml"/><item><title>5.1 Rust 是健全的</title><link>https://before80.github.io/prgms/Rust/comprehensiveRust/unsafe/rules-of-the-game/01-rust-is-sound/</link><pubDate>Tue, 11 Aug 2026 11:30:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/comprehensiveRust/unsafe/rules-of-the-game/01-rust-is-sound/</guid><description>&lt;blockquote&gt;
&lt;p&gt;译文 · 基于 &lt;a href="https://google.github.io/comprehensive-rust/"&gt;Comprehensive Rust&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://google.github.io/comprehensive-rust/unsafe-deep-dive/rules-of-the-game/rust-is-sound.html"&gt;https://google.github.io/comprehensive-rust/unsafe-deep-dive/rules-of-the-game/rust-is-sound.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="51-rust-是健全的"&gt;5.1 Rust 是健全的&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;健全性（soundness）是 Rust 的基础&lt;/li&gt;
&lt;li&gt;健全性 ≈ 不可能引发内存安全问题&lt;/li&gt;
&lt;li&gt;健全函数具有一些共同的「形态」&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;「Rust 代码的一项基本原则是：它是健全的。&lt;/p&gt;</description></item><item><title>5.3 健全 Rust 的三种形态</title><link>https://before80.github.io/prgms/Rust/comprehensiveRust/unsafe/rules-of-the-game/02-3-shapes-of-sound-rust/</link><pubDate>Tue, 11 Aug 2026 11:30:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/comprehensiveRust/unsafe/rules-of-the-game/02-3-shapes-of-sound-rust/</guid><description>&lt;blockquote&gt;
&lt;p&gt;译文 · 基于 &lt;a href="https://google.github.io/comprehensive-rust/"&gt;Comprehensive Rust&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://google.github.io/comprehensive-rust/unsafe-deep-dive/rules-of-the-game/3-shapes-of-sound-rust.html"&gt;https://google.github.io/comprehensive-rust/unsafe-deep-dive/rules-of-the-game/3-shapes-of-sound-rust.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="53-健全-rust-的三种形态"&gt;5.3 健全 Rust 的三种形态&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;完全用 Safe Rust 编写的函数&lt;/li&gt;
&lt;li&gt;包含不可能被误用的 &lt;code&gt;unsafe&lt;/code&gt; 块的函数&lt;/li&gt;
&lt;li&gt;已记录安全前置条件的不安全（unsafe）函数&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;我们要编写健全代码。&lt;/li&gt;
&lt;li&gt;健全代码只能有以下形态：
&lt;ul&gt;
&lt;li&gt;不含 &lt;code&gt;unsafe&lt;/code&gt; 块的安全函数&lt;/li&gt;
&lt;li&gt;完全封装 &lt;code&gt;unsafe&lt;/code&gt; 块的安全函数，即调用方无需了解其中的 &lt;code&gt;unsafe&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;包含 &lt;code&gt;unsafe&lt;/code&gt; 块但未将其封装、把证明责任转嫁给调用方的不安全函数&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;证明责任
&lt;ul&gt;
&lt;li&gt;仅含 Safe Rust 的安全函数 → 编译器&lt;/li&gt;
&lt;li&gt;含 &lt;code&gt;unsafe&lt;/code&gt; 块的安全函数 → 函数作者&lt;/li&gt;
&lt;li&gt;不安全函数 → 函数调用方&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;</description></item></channel></rss>