Function that returns impl Iterator<Item = Box<dyn Iterator<Item = i32>>>

Yes, a neat little trick @quinedot showed me :slightly_smiling_face: :

I guess you can use the _ placeholder here, because the compiler can infer the type it should coerce to from your function signature's return type. It just needs a nudge to do the coercion, because of the added indirection from the outer call to once. The topic I linked was me struggling to do trait object coercion with collections, which boils down to the same behaviour of Rust's type inference that you experienced with your problem here, I'd say.

1 Like