I've got some code that attempts to run a match where each branch can return a different type, but all of these types implement Iterator<Item=usize>
.
let found: Iterator<Item = usize> = match requirements {
Requirements::A => MatchingAs { ainternals: [] },
Requirements::B => MatchingBs { binternals: [] },
Requirements::C => MatchingCs { cinternals: [] },
};
return found.any(|m| m == 1)
... where MatchingAs
, MatchingBs
, and MatchingCs
all impl
std::iter::Iterator<Item = usize>
.
I'm hitting a wall with the fact that the Iterator
isn't sized:
| the trait `std::marker::Sized` is not implemented for `std::iter::Iterator<Item=usize>`
Is there a good approach to have match arms return objects with a shared trait, and then rely (only) on the trait in processing the results?