Hey folks
I've seen the new blog post about RTN, there you can read:
Currently, RTN is only allowed for trait associated functions and methods with lifetime generics (not const or type generics) that use:
async fn in traits (AFIT) or
return-position impl Trait in traits (RPITIT) where the impl Trait is the outermost return type, i.e.-> impl Trait
, but not-> Box<impl Trait>
.These restrictions are described in further detail in RFC 3654.
I understand the point in the RFC why you can only use it currently with AFIT and RPITIT but I cannot find any real explaination why RTN cannot be used with functions/methods that have const or type generics. The RFC says at least:
The method named in an RTN type may have generic parameters (e.g.,
fn widgets<'a>(&'a self)
has a lifetime parameter'a
). Because RTN locations are limited to where-clauses and trait bounds in this RFC, these parameters can always be captured in a for to form a higher-ranked trait bound.
So is the generic lifetime only support here a design decision to make sure that RTNs - always - work with HRTBs or are there any other reasons for this restriction?
Regards
keks
PS: I ask this just out of curiosity because I want to understand it.