Rust stabilizes generic associated types

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • rust

    Empowering everyone to build reliable and efficient software.

  • Here's some history of the GATS, from the original author of the RFC and how their sole purpose is to not have to add HKTS.

    https://github.com/rust-lang/rust/pull/96709#issuecomment-11...

  • rfcs

    RFCs for changes to Rust

  • Well you don't have to use it just because it is added, but it will allow library writers to provide more ergonomic interfaces. This specific type system feature allows for stuff that weren't possible before but make sense and you'd expect to be valid code that compiles:

    the most common example is the lending iterator. Have a struct that owns a vector of data. Can you implement an iterator that can return a reference of each item when you call next()? Not without GATs, because each time you return from next() you're creating a new lifetime that doesn't exist in your trait definition.

    That's why current standard library iterators are basically structs that own a reference to what you iterate. See the GAT RFC which explains this concept much better than I can:

    https://github.com/rust-lang/rfcs/blob/master/text/1598-gene...

    TL;DR it's not a "new" feature per se but something that could have been present from the beginning without making the language different.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts