<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mem-Replace on rustbites</title><link>https://www.rustbites.com/tags/mem-replace/</link><description>Recent content in Mem-Replace on rustbites</description><generator>Hugo</generator><language>en</language><lastBuildDate>Fri, 12 Jun 2026 15:32:50 +0200</lastBuildDate><atom:link href="https://www.rustbites.com/tags/mem-replace/index.xml" rel="self" type="application/rss+xml"/><item><title>197. Advance a State Machine with mem::replace — Move the Enum Out, No Clone</title><link>https://www.rustbites.com/posts/bite-197/</link><pubDate>Fri, 12 Jun 2026 09:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-197/</guid><description>&lt;p&gt;Transitioning an enum state behind &lt;code&gt;&amp;amp;mut self&lt;/code&gt; looks impossible: you can&amp;rsquo;t move the old variant&amp;rsquo;s owned data into the new one without the borrow checker stopping you — so people reach for &lt;code&gt;.clone()&lt;/code&gt;. &lt;code&gt;mem::replace&lt;/code&gt; lets you move the &lt;em&gt;whole&lt;/em&gt; state out, leaving a cheap placeholder behind.&lt;/p&gt;</description></item></channel></rss>