GATs and the Inside Rust Blog from late September/2024

Hi,

The blog I mentioned is this one: Return type notation MVP: Call for testing! | Inside Rust Blog

I have a doubt related to this point: the article explains that AFITs and RPITITs are desugared to GATs, and it suggests that we can assist by identifying traits that currently return GATs just to include more bounds. And then they show this example:

trait Foo {
 type MethodFuture: Future<Output = ()>;
 fn method() -> Self::MethodFuture;
}

Is that really a GAT?
Aren't GATs (Generic Associated Types) associated types that include a lifetime or a generic type?
I can't see any generic component within this one, it's simply bounded by a Future trait...

What am I missing? Thank you.

If we insist on strictly differentiating non-generic associated types and GATs, you're correct; if there are no generics on the method,[1] the desugaring is a non-generic associated type and not a GAT.

AFITs/RPITITs desugar to associated types with the same number of generic parameters as the method,[2] and that number could be 0.


  1. or "method"; this is technically an associated function ↩︎

  2. modulo use bounds ↩︎

3 Likes

Humm, thanks, @quinedot!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.