<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Oncecell on rustbites</title><link>https://www.rustbites.com/tags/oncecell/</link><description>Recent content in Oncecell on rustbites</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 21 May 2026 10:32:45 +0200</lastBuildDate><atom:link href="https://www.rustbites.com/tags/oncecell/index.xml" rel="self" type="application/rss+xml"/><item><title>153. OnceCell&lt;T&gt; — Memoize Through &amp;self Without Wrapping in RefCell</title><link>https://www.rustbites.com/posts/bite-153/</link><pubDate>Thu, 21 May 2026 09:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-153/</guid><description>&lt;p&gt;You have a &lt;code&gt;parse(&amp;amp;self) -&amp;gt; &amp;amp;Heavy&lt;/code&gt; accessor that needs to compute once and cache. &lt;code&gt;&amp;amp;self&lt;/code&gt; rules out a plain field assignment. &lt;code&gt;Cell&lt;/code&gt; needs &lt;code&gt;Copy&lt;/code&gt;. &lt;code&gt;RefCell&lt;/code&gt; won&amp;rsquo;t lend the inside out past &lt;code&gt;.borrow()&lt;/code&gt;. &lt;code&gt;OnceCell&amp;lt;T&amp;gt;&lt;/code&gt; is the missing piece — write-once, &lt;code&gt;&amp;amp;self&lt;/code&gt; API, hands back a real &lt;code&gt;&amp;amp;T&lt;/code&gt; that lives as long as the cell.&lt;/p&gt;</description></item></channel></rss>