<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>2.4 内部可变性 on 编程那些事儿</title><link>https://before80.github.io/prgms/Rust/comprehensiveRust/day3-afternoon/borrowing/interior-mutability/</link><description>Recent content in 2.4 内部可变性 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/day3-afternoon/borrowing/interior-mutability/index.xml" rel="self" type="application/rss+xml"/><item><title>2.4.1 `Cell`</title><link>https://before80.github.io/prgms/Rust/comprehensiveRust/day3-afternoon/borrowing/interior-mutability/01-cell/</link><pubDate>Tue, 11 Aug 2026 11:30:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/comprehensiveRust/day3-afternoon/borrowing/interior-mutability/01-cell/</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/borrowing/interior-mutability/cell.html"&gt;https://google.github.io/comprehensive-rust/borrowing/interior-mutability/cell.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="241-cell"&gt;2.4.1 &lt;code&gt;Cell&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;Cell&lt;/code&gt; 包装一个值，并允许仅通过指向 &lt;code&gt;Cell&lt;/code&gt; 的共享引用来获取或设置该值。但它不允许任何指向内部值的引用。由于没有引用，借用规则也就无法被破坏。&lt;/p&gt;</description></item><item><title>2.4.2 `RefCell`</title><link>https://before80.github.io/prgms/Rust/comprehensiveRust/day3-afternoon/borrowing/interior-mutability/02-refcell/</link><pubDate>Tue, 11 Aug 2026 11:30:00 +0800</pubDate><guid>https://before80.github.io/prgms/Rust/comprehensiveRust/day3-afternoon/borrowing/interior-mutability/02-refcell/</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/borrowing/interior-mutability/refcell.html"&gt;https://google.github.io/comprehensive-rust/borrowing/interior-mutability/refcell.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="242-refcell"&gt;2.4.2 &lt;code&gt;RefCell&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;RefCell&lt;/code&gt; 允许访问并修改被包装的值，方式是提供模拟 &lt;code&gt;&amp;amp;T&lt;/code&gt;/&lt;code&gt;&amp;amp;mut T&lt;/code&gt;、但并非真正 Rust 引用的替代类型 &lt;code&gt;Ref&lt;/code&gt; 与 &lt;code&gt;RefMut&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;这些类型使用 &lt;code&gt;RefCell&lt;/code&gt; 中的计数器进行动态检查，防止 &lt;code&gt;RefMut&lt;/code&gt; 与另一个 &lt;code&gt;Ref&lt;/code&gt;/&lt;code&gt;RefMut&lt;/code&gt; 同时存在。&lt;/p&gt;</description></item></channel></rss>