<story><title>Rust: “Explain GATs Like I&apos;m 5 Years Old”</title><url>https://old.reddit.com/r/rust/comments/ynvm8a/could_someone_explain_the_gats_like_i_was_5/</url></story><parent_chain><item><author>nicoburns</author><text>I think the easiest way to understand it is this:&lt;p&gt;Suppose you have a concrete type like&lt;p&gt;&lt;pre&gt;&lt;code&gt;    Vec&amp;lt;i32&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
Regular generics enable you to make the contained type generic, so you have:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    Vec&amp;lt;T&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
where T can be i32, u32, String, etc. GATs allow you to make the &lt;i&gt;container&lt;/i&gt; generic. So you can have:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    T&amp;lt;i32&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
where T might be Vec, Option, Box, etc.</text></item><item><author>the__alchemist</author><text>I&amp;#x27;m filing this one along with Monads and Haskell as programming concepts that I&amp;#x27;ll never understand. Rust is my favorite language, but that explanation, lauded directly below it as &lt;i&gt;This is personally the easiest to understand example I&amp;#x27;ve seen of GATs.&lt;/i&gt;, was incomprehensible.</text></item></parent_chain><comment><author>brap</author><text>Thanks, this was much easier to understand than the original article. What will I use this for? Usually for the “T” to be useful it needs to have some interface. In Java I’d just use Collection&amp;lt;Integer&amp;gt; or something more abstract.</text></comment>
<story><title>Rust: “Explain GATs Like I&apos;m 5 Years Old”</title><url>https://old.reddit.com/r/rust/comments/ynvm8a/could_someone_explain_the_gats_like_i_was_5/</url></story><parent_chain><item><author>nicoburns</author><text>I think the easiest way to understand it is this:&lt;p&gt;Suppose you have a concrete type like&lt;p&gt;&lt;pre&gt;&lt;code&gt;    Vec&amp;lt;i32&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
Regular generics enable you to make the contained type generic, so you have:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    Vec&amp;lt;T&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
where T can be i32, u32, String, etc. GATs allow you to make the &lt;i&gt;container&lt;/i&gt; generic. So you can have:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    T&amp;lt;i32&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
where T might be Vec, Option, Box, etc.</text></item><item><author>the__alchemist</author><text>I&amp;#x27;m filing this one along with Monads and Haskell as programming concepts that I&amp;#x27;ll never understand. Rust is my favorite language, but that explanation, lauded directly below it as &lt;i&gt;This is personally the easiest to understand example I&amp;#x27;ve seen of GATs.&lt;/i&gt;, was incomprehensible.</text></item></parent_chain><comment><author>philzook</author><text>What you&amp;#x27;re describing sounds to me like higher kinded types, which are of some relationship to GATs (GATs enable a better encoding of higher kinded types as I understand it), but are not GATs. &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;docs.rs&amp;#x2F;higher&amp;#x2F;latest&amp;#x2F;higher&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;docs.rs&amp;#x2F;higher&amp;#x2F;latest&amp;#x2F;higher&amp;#x2F;&lt;/a&gt;</text></comment>