<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>rust on Suriya's site</title><link>https://subygan.com/tech/practice/rust/</link><description>Recent content in rust on Suriya's site</description><generator>Hugo</generator><language>en</language><copyright>This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.</copyright><item><title>rust `move` keyword</title><link>https://subygan.com/tech/practice/rust/move/</link><pubDate>Tue, 09 Sep 2025 00:00:00 +0000</pubDate><guid>https://subygan.com/tech/practice/rust/move/</guid><description>&lt;h2 id="what-is-move">what is &amp;ldquo;move&amp;rdquo;&lt;/h2>
&lt;p>When you assign a value to a new variable or pass a value to a function, the default behavior for types that don&amp;rsquo;t implement the &lt;code>Copy&lt;/code> trait is to &amp;ldquo;move&amp;rdquo; ownership of that value. This means the original variable can no longer be used after the move. This prevents double-free errors and other memory safety issues by ensuring there&amp;rsquo;s always only one owner of the data at any given time. This forms the base of the ownership model, which can be represented like below.&lt;/p></description></item><item><title>async rust</title><link>https://subygan.com/tech/practice/rust/async-rust/</link><pubDate>Sun, 10 Aug 2025 00:00:00 +0000</pubDate><guid>https://subygan.com/tech/practice/rust/async-rust/</guid><description>&lt;p>Asynchronous programming is a powerful paradigm for building highly concurrent and efficient I/O-bound applications.&lt;/p>
&lt;p>I will dissect the core components of Rust&amp;rsquo;s asynchrony, from the fundamental &lt;code>Future&lt;/code> trait to the complexities of &lt;code>Pin&lt;/code> and memory management. We will then unravel the inner workings of Tokio, the most popular async runtime, exploring its scheduler, I/O handling with &lt;code>mio&lt;/code>, and how it all comes together to execute our asynchronous code.&lt;/p></description></item><item><title>rust benchmarking</title><link>https://subygan.com/tech/practice/rust/benchmarking/</link><pubDate>Wed, 25 Jun 2025 00:00:00 +0000</pubDate><guid>https://subygan.com/tech/practice/rust/benchmarking/</guid><description>&lt;h2 id="libraries">libraries&lt;/h2>
&lt;h3 id="criterionrs">&lt;a href="https://github.com/bheisler/criterion.rs">criterion.rs&lt;/a>
&lt;/h3>
&lt;ul>
&lt;li>Has really good defaults and seems to work out of the box.&lt;/li>
&lt;li>The ecosystem around criterion is really good. purely because criterion has been around for so long&lt;/li>
&lt;/ul>
&lt;h3 id="rust-iai">&lt;a href="https://github.com/bheisler/iai">rust iai&lt;/a>
&lt;/h3>
&lt;p>Even though it is supported by a lot of ecosystem tools. It hasn&amp;rsquo;t been in development for the past 4 years. and &lt;a href="https://github.com/bheisler">bheisler&lt;/a>
 is the creator of criterion, so even more reason to use criterion.&lt;/p></description></item><item><title>rust cheatsheet</title><link>https://subygan.com/tech/practice/rust/cheatsheet/</link><pubDate>Wed, 28 Feb 2024 00:00:00 +0000</pubDate><guid>https://subygan.com/tech/practice/rust/cheatsheet/</guid><description>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-rust" data-lang="rust">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">let&lt;/span> x; &lt;span style="color:#75715e">// declare &amp;#34;x&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>x &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#ae81ff">42&lt;/span>; &lt;span style="color:#75715e">// assign 42 to &amp;#34;x&amp;#34;, type is inferred
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>or&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-rust" data-lang="rust">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">let&lt;/span> x &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#ae81ff">42&lt;/span> &lt;span style="color:#75715e">//assigns variable
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">let&lt;/span> x: &lt;span style="color:#66d9ef">i32&lt;/span>; &lt;span style="color:#75715e">//declaring variable &amp;#34;x&amp;#34; of 32 bit integer
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>foobar(x); &lt;span style="color:#75715e">//uninitialised variable assignment
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>x &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#ae81ff">52&lt;/span>; &lt;span style="color:#75715e">// assigning 52
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>foobar(x); &lt;span style="color:#75715e">//x will be called
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>x &lt;span style="color:#f92672">=&lt;/span> x &lt;span style="color:#f92672">+&lt;/span> &lt;span style="color:#ae81ff">12&lt;/span>; &lt;span style="color:#75715e">// x = 64 now
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">let&lt;/span> _ &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#ae81ff">42&lt;/span>; &lt;span style="color:#75715e">// does nothing, since 42 is a constant and _ is a placeholder
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">let&lt;/span> _ &lt;span style="color:#f92672">=&lt;/span> get_function(); &lt;span style="color:#75715e">//calls function and throws away the result
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">let&lt;/span> _x &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#ae81ff">42&lt;/span>; &lt;span style="color:#75715e">//compiler wont warn about unused variable
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Just like in all languages elements within objects can be called using a dot.&lt;/p></description></item><item><title/><link>https://subygan.com/tech/practice/rust/patterns/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://subygan.com/tech/practice/rust/patterns/</guid><description/></item></channel></rss>