3 ms·
Context for those who don't follow Rust development closely: This release stabilises Generic Associated Types (GATs), a limited form of Higher Kinded Types. Th
by nicoburns 4y ago
Context for those who don't follow Rust development closely:
This release stabilises Generic Associated Types (GATs), a limited form of Higher Kinded Types. This is only an MVP release, but it already includes enough to be useful, and has been a huge multi-year effort (the RFC for the feature dates to April 2016).
Novice users of Rust probably won't use this feature directly, but it gives a lot more power to library authors to write more flexible APIs while still keeping all of Rust's strict correctness guardrails (i.e. exposing a safe API). It will also form the basis of the upcoming "async functions in traits" feature.
This is probably the most significant Rust release in the last couple of years.
- zozbot234 4y agoThe stabilization of GAT's was previously discussed https://news.ycombinator.com/item?id=32829806 https://news.ycombinator.com/item?id=32829806 From that thread, a link https://www.fpcomplete.com/blog/monads-gats-nightly-rust/ https://www.fpcomplete.com/blog/monads-gats-nightly-rust/ to a comparison of GAT's w/ HKTs as seen in high-level functional languages. Note that the version of GAT's provided here is a MVP and might be unable to express some of these patterns.
- 4m1rk 4y agoThis topic made me think that you'll eventually have to support all FP principles in a strongly type safe language like Rust which reminds me of Scala FP community. I'm not sure if it ended up being a good thing for Scala long-term. I also wonder whether Linux kernel community would adapt these concepts or reject them for the sake of KISS.
- queuebert 4y agoBest thing since const generics.
- afranchuk 4y agoI agree with the significance. I've liked the additions over the past few years of course, but the last time I felt a release was this significant was async, I believe 1.39, about 3 years ago. And coincidentally, the times I've wanted to reach for GATs have been when dealing with Futures (specifically dealing with lifetimes of Futures produced by Fns; basically what gates async functions in traits). I'm excited to be able to finally use them in my APIs!
- echelon 4y agoNo kidding, this is big! Data structures are going to get easier. > It will also form the basis of the upcoming "async functions in traits" feature. I can stop using https://crates.io/crates/async-trait https://crates.io/crates/async-trait !
- kibwen 4y agoNot just yet, the two big blockers on async methods are: 1. The ability to use generics in associated types 2. The ability to use `impl Trait` in associated types GATs provide the first, but the latter is still being worked on. The good news is that the implementation has matured greatly this year and appears to be in a state where stabilization could be considered. AFAICT this work is being done in the broader context of async methods, tracked here: https://github.com/rust-lang/rust/issues/91611 https://github.com/rust-lang/rust/issues/91611