<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mukherjeemahadev84-tech</title>
    <description>The latest articles on DEV Community by mukherjeemahadev84-tech (@mukherjeemahadev84tech).</description>
    <link>https://dev.to/mukherjeemahadev84tech</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4206804%2Ffb4269ea-1d71-4272-8892-09fd3a8ed237.jpg</url>
      <title>DEV Community: mukherjeemahadev84-tech</title>
      <link>https://dev.to/mukherjeemahadev84tech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mukherjeemahadev84tech"/>
    <language>en</language>
    <item>
      <title>Why Rust says value moved, explained with a house key</title>
      <dc:creator>mukherjeemahadev84-tech</dc:creator>
      <pubDate>Mon, 23 Nov 2026 08:30:00 +0000</pubDate>
      <link>https://dev.to/mukherjeemahadev84tech/why-rust-says-value-moved-explained-with-a-house-key-hd2</link>
      <guid>https://dev.to/mukherjeemahadev84tech/why-rust-says-value-moved-explained-with-a-house-key-hd2</guid>
      <description>&lt;h2&gt;
  
  
  The error that confuses almost every Rust beginner
&lt;/h2&gt;

&lt;p&gt;You write three lines of Rust, hit compile, and get an error about a borrow of a moved value. The code looks harmless, so the error feels unfair.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"{}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The house key
&lt;/h2&gt;

&lt;p&gt;Think of it like handing someone your only house key. Once you give it away, you cannot also use it yourself.&lt;/p&gt;

&lt;p&gt;That is what let s2 = s1 does. A String owns its text in memory, and Rust allows only one owner at a time. After the assignment, s2 holds the key and s1 holds nothing. When the next line tries to print s1, the compiler stops you, because s1 no longer owns anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Rust does this
&lt;/h2&gt;

&lt;p&gt;Other languages would quietly copy the text or let both names point at the same memory. Copying costs time, and sharing causes bugs when one name frees the memory while the other still uses it. Rust avoids both by tracking a single owner and checking it before the program ever runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two ways to fix it
&lt;/h2&gt;

&lt;p&gt;If you need both variables to own their own text, make a real copy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"{}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"{}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clone makes a full copy, so each variable owns separate data and both stay valid.&lt;/p&gt;

&lt;p&gt;If you only need to read the text, borrow it instead of taking it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"{}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"{}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now s2 is only a reference. The key never left s1, so s1 stays valid.&lt;/p&gt;

&lt;h2&gt;
  
  
  A habit that helps
&lt;/h2&gt;

&lt;p&gt;Whenever a move error appears, ask who owns the value right now. Most of these errors disappear once you can answer that.&lt;/p&gt;

&lt;p&gt;I built a small tool called BorrowFix that explains 20 common Rust compiler errors this way, with an analogy first, then the real error, the concept and the fix. You can try it here: &lt;a href="https://borrowfix-smoky.vercel.app" rel="noopener noreferrer"&gt;https://borrowfix-smoky.vercel.app&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which Rust error confused you the most when you were learning? I would like to add it next.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>webdev</category>
      <category>programming</category>
      <category>devops</category>
    </item>
    <item>
      <title>Rust tip: when you see "borrow of moved value", ask who owns the value right now. A String has one owner at a time, like a single house key. Hand it over and you cannot use it yourself. Fix it with clone or a borrow. #rust #beginners</title>
      <dc:creator>mukherjeemahadev84-tech</dc:creator>
      <pubDate>Sun, 22 Nov 2026 19:02:33 +0000</pubDate>
      <link>https://dev.to/mukherjeemahadev84tech/rust-tip-when-you-see-borrow-of-moved-value-ask-who-owns-the-value-right-now-a-string-has-one-1j67</link>
      <guid>https://dev.to/mukherjeemahadev84tech/rust-tip-when-you-see-borrow-of-moved-value-ask-who-owns-the-value-right-now-a-string-has-one-1j67</guid>
      <description></description>
      <category>beginners</category>
      <category>programming</category>
      <category>rust</category>
    </item>
    <item>
      <title>I built a tool that explains Rust compiler errors with an analogy first</title>
      <dc:creator>mukherjeemahadev84-tech</dc:creator>
      <pubDate>Sun, 25 Oct 2026 15:17:23 +0000</pubDate>
      <link>https://dev.to/mukherjeemahadev84tech/i-built-a-tool-that-explains-rust-compiler-errors-with-an-analogy-first-106f</link>
      <guid>https://dev.to/mukherjeemahadev84tech/i-built-a-tool-that-explains-rust-compiler-errors-with-an-analogy-first-106f</guid>
      <description>&lt;h2&gt;
  
  
  The wall every Rust beginner hits
&lt;/h2&gt;

&lt;p&gt;If you have learned Rust, you remember the first time the borrow checker stopped you. The code looked fine, you hit compile, and the screen filled with an error about moved values or lifetimes. Rust has some of the best compiler messages of any language, but they quietly assume you already understand ownership. For a beginner, that help does not land. It feels like a wall, and this is where a lot of people give up.&lt;/p&gt;

&lt;p&gt;I wanted something that explains the error, not just the fix. So I built BorrowFix.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;p&gt;You pick one of 20 curated Rust compiler errors, or paste your own broken code. The site sends it to a small backend that runs rustc and returns the real compiler error. It only compiles the code and never runs it, which keeps things simple and safe.&lt;/p&gt;

&lt;p&gt;The first version showed the error and a paragraph of explanation. It was accurate, and it read like a manual.&lt;/p&gt;

&lt;h2&gt;
  
  
  The feedback that changed the design
&lt;/h2&gt;

&lt;p&gt;After I shared it on LinkedIn, Divyesh Kakadiya, a backend engineer who works in Rust and Go, tried it and left two suggestions. First, start with a simple analogy before the compiler error. Second, show the fixed code right next to the explanation, so a beginner can connect the error, the concept and the fix in one view.&lt;/p&gt;

&lt;p&gt;Both were right. I rebuilt all 20 errors around that order: an analogy, the real compiler error, the Rust concept behind it, the fixed code, and a line on why the fix works.&lt;/p&gt;

&lt;h2&gt;
  
  
  A before and after
&lt;/h2&gt;

&lt;p&gt;Take the classic moved value error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before, the explanation said that assigning s1 to s2 moves ownership, so s1 is no longer valid. Now it starts like this: think of it like handing someone your only house key. Once you give it away, you cannot also use it yourself. Then comes the real error, then the concept (Strings own heap memory, and only one owner is allowed at a time), and then the fix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="nf"&gt;.clone&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last line explains why it works: clone makes a full copy, so s1 and s2 each own separate data and both stay valid.&lt;/p&gt;

&lt;p&gt;Here is another one, two mutable borrows at once.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;r1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{} {}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The analogy is two people editing the same document at the same instant with no lock, where one person's changes silently vanish. Rust blocks that at compile time instead of letting it turn into a data race at runtime. The fix is to let r1 finish its work inside its own block before r2 starts a new borrow.&lt;/p&gt;

&lt;h2&gt;
  
  
  A technical detour worth sharing
&lt;/h2&gt;

&lt;p&gt;I first planned to use Piston, the open source code execution engine, and self-host it on Railway. It failed. Piston relies on an isolation tool that needs privileged container access, and most hosting platforms, Railway included, do not allow that. The container started, but Piston crashed inside it with a read-only file system error.&lt;/p&gt;

&lt;p&gt;Since I only needed compile checks for curated examples, I replaced it with a small Node and Express service that calls rustc directly with a timeout, a fresh temporary folder for every request, and no execution of the compiled output. The frontend is a static page on Vercel. It is a small setup, and it was enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would like from you
&lt;/h2&gt;

&lt;p&gt;BorrowFix is early and rough in places. If you are learning Rust or teach it, tell me which compiler error confused you the most and what finally made it click. I will add it next.&lt;/p&gt;

&lt;p&gt;You can try it here: &lt;a href="https://borrowfix-smoky.vercel.app" rel="noopener noreferrer"&gt;https://borrowfix-smoky.vercel.app&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>webdev</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
