<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
    <title>bigfish的网络博客 - 学习笔记</title>
    <subtitle>记录技术和生活</subtitle>
    <link rel="self" type="application/atom+xml" href="https://blog.laofu.online/tags/xue-xi-bi-ji/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://blog.laofu.online"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-10-03T00:00:00+00:00</updated>
    <id>https://blog.laofu.online/tags/xue-xi-bi-ji/atom.xml</id>
    <entry xml:lang="zh">
        <title>Rust 所有权：为什么值是我的，我却不能改？</title>
        <published>2026-10-03T00:00:00+00:00</published>
        <updated>2026-10-03T00:00:00+00:00</updated>
        
        <author>
          <name>bigfish</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.laofu.online/blog/20261003-rust-ownership/"/>
        <id>https://blog.laofu.online/blog/20261003-rust-ownership/</id>
        
        <summary type="html">&lt;p&gt;读 Rust 代码时，很容易卡在这样两行上：&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-8&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;z-l-3&quot;&gt; tools&lt;/span&gt;&lt;span class=&quot;z-d-8&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-6&quot;&gt; build_tools&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-d-8&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-3&quot;&gt;ctx&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-3&quot;&gt; args&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-8&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-8&quot;&gt; mut&lt;/span&gt;&lt;span class=&quot;z-l-3&quot;&gt; tools&lt;/span&gt;&lt;span class=&quot;z-d-8&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-3&quot;&gt; tools&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;同一个名字怎么能声明两次？第二行已经拿到了所有权，为什么还要写 &lt;code&gt;mut&lt;/code&gt;？既然东西归我，难道还不能改吗？&lt;/p&gt;
&lt;p&gt;如果之前主要写 Java、C# 或 JavaScript，这种困惑很自然。我们习惯了把对象交给另一个变量，再从任何一个变量修改它。Rust 把这里的几件事分开了，需要稍微换一下思路。&lt;/p&gt;
&lt;p&gt;这篇笔记从这些具体问题讲起。先看常见场景，最后留几道题，可以自己判断一下，不用急着记术语。&lt;/p&gt;</summary>
        
    </entry>
</feed>
