2 ms·
The only thing new in Rust 2018 is the impl Trait in argument position. Generics and trait bounds are in the language from the start. So you can write this fu
by veber-alex 5y ago
The only thing new in Rust 2018 is the impl Trait in argument position.
Generics and trait bounds are in the language from the start.
So you can write this function like this:
fn twiddle<T: IntoIterator<Item = Foozle>>(foozles: T)
Which is 100% idiomatic today and is even preferred by some people over using impl Trait
- slaymaker1907 5y agoimpl 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.