Heya everyone, I'm having an issue with opaque types/not fully understanding how to get around an issue I'm having. (also not even fully sure if I understand the issue)
for the example I have 3 functions that return a type of impl Iterator<Item = &'a u32> but when I try to use them all with a match statement I get an error saying my match branches are incompatible since expected opaque type, found a different opaque type because note: distinct uses of 'impl Trait' result in different opaque types
this first link is the non-working code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=97046c19ead967cd50dc935717e64dec
this next bit of code works, however using Box<dyn>/dynamic dispatch is probably not the best idea? I'm not sure how drastic the penalties are for it, but I think they're bad (in my real application the chains are much larger, multiple levels deep, etc, perhaps it is the best solution in my real case?, if someone happens to know/have any resources on dispatching I'd love to see them): https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3ccbae7e26a419227c74910dd065a574
One solution i found was https://rust-lang.github.io/impl-trait-initiative/explainer/tait.html but it's nightly and i would like to stay on a stable branch
Thank you for any suggestions in advance, have a great day