<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Traits on vrajat</title><link>https://vrajat.com/tags/traits/</link><description>Recent content in Traits on vrajat</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 05 May 2026 12:00:00 +0530</lastBuildDate><atom:link href="https://vrajat.com/tags/traits/index.xml" rel="self" type="application/rss+xml"/><item><title>Rust Static and Dynamic Dispatch</title><link>https://vrajat.com/posts/rust-static-dynamic-dispatch/</link><pubDate>Tue, 05 May 2026 12:00:00 +0530</pubDate><guid>https://vrajat.com/posts/rust-static-dynamic-dispatch/</guid><description>&lt;p>In Java, there are two broad use cases for type abstraction:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Compile-time polymorphism&lt;/strong>: A class or function works over different data types while preserving type safety.
For example, &lt;code>ArrayList&amp;lt;User&amp;gt;&lt;/code>, &lt;code>HashMap&amp;lt;String, Double&amp;gt;&lt;/code>, &lt;code>Optional&amp;lt;User&amp;gt;&lt;/code>.
The compiler ensures that there is no type mismatch and prevents a variable
of type &lt;code>ArrayList&amp;lt;User&amp;gt;&lt;/code> from being assigned an &lt;code>ArrayList&amp;lt;String&amp;gt;&lt;/code>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Runtime polymorphism&lt;/strong>: The code uses the advertised capabilities of an interface but does not determine
the concrete implementation. For example, a method accepts &lt;code>List&amp;lt;User&amp;gt;&lt;/code> but
the caller can pass &lt;code>ArrayList&amp;lt;User&amp;gt;&lt;/code> or &lt;code>LinkedList&amp;lt;User&amp;gt;&lt;/code>.&lt;/p></description></item><item><title>Understanding Rust Associated Types</title><link>https://vrajat.com/posts/rust-associated-types/</link><pubDate>Sun, 15 Mar 2026 12:00:00 +0530</pubDate><guid>https://vrajat.com/posts/rust-associated-types/</guid><description>&lt;p>&lt;a href="https://github.com/vrajat/pgqrs">pgqrs&lt;/a> supports multiple databases including PostgreSQL and SQLite.&lt;/p>
&lt;p>An application uses &lt;code>pgqrs&lt;/code> with a specific database that is chosen as a feature.&lt;/p>
&lt;pre tabindex="0">&lt;code>[dependencies]
# PostgreSQL only (default)
pgqrs = &amp;#34;0.15.2&amp;#34;

# SQLite only
pgqrs = { version = &amp;#34;0.15.1&amp;#34;, default-features = false, features = [&amp;#34;sqlite&amp;#34;] }
&lt;/code>&lt;/pre>&lt;p>The choice of database determines:&lt;/p>
&lt;ul>
&lt;li>dialect&lt;/li>
&lt;li>client library&lt;/li>
&lt;li>specific functions such as handling timestamps.&lt;/li>
&lt;/ul>
&lt;p>The important detail is that these differences are not chosen per method call.
Once the backend is selected, the dialect and timestamp handling are fixed.&lt;/p></description></item></channel></rss>