Re:C++ Coroutines Do Not Spark Joy
by slaymaker1907 on Monday November 01, 2021 @04:51PM
(#29072942)
impl Trait as the return type actually added quite a bit more than in argument position. In particular, it allows you to return a lambda without boxing since you cannot get the exact return type of a lambda (at least not yet). impl return types are sort of a special case of existential typing.
Generics and trait bounds are in the language from the start.
So you can write this function like this:
Which is 100% idiomatic today and is even preferred by some people over using impl Trait