Hi, I don’t know if this is possible, or maybe this is hard to implement.
I think we need to allow impl Trait
in Fn() -> impl Trait
,
here the reason for it.
What do you think?
Hi, I don’t know if this is possible, or maybe this is hard to implement.
I think we need to allow impl Trait
in Fn() -> impl Trait
,
here the reason for it.
What do you think?
I think this is rust-lang/rust#45994, although that’s a very short issue.
As far as I know this case should be equivalent to other traits associated types, which work already (playground), but for some reason the Fn
type sugar disallows this. The linked issue mentions HRTB, so maybe that’s why it wouldn’t be as straightforward for Fn
types, but I’m not sure exactly how that interacts with it.
fn foo() -> impl Iterator<Item = impl std::fmt::Debug> {
vec![5].into_iter()
}
fn main() {
for i in foo() {
println!("{:?}", i);
}
}
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.