2 ms·
Rust couldn't return Traits since they vary in return Size.So using couple of chain and maps would result in following syntax. fn did_too_many_chains() ->
by Ygg2 10y ago
Rust couldn't return Traits since they vary in return Size.So using couple of chain and maps would result in following syntax.
fn did_too_many_chains() -> Chain<Map<'a, (int, u8), u16, Enumerate<Filter<'a, u8, vec::MoveItems<u8>>>>, SkipWhile<'a, u16, Map<'a, &u16, u16, slice::Items<u16>>>>
Now, you can write:
fn did_too_many_chains() -> impl Iterator
and be done with it.
- fnord123 10y agoThat's awesome. I've been banging my head against the wall trying to implement a Drain iterator for a tree structure and it tries to recurse. I ended up with things like your Chain<Map...>> and was banging my head against the wall over it.