Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRustimpl TraitSingle-choice MCQ

Why does returning `impl Iterator` from these two branches fail to compile?

fn pick(flag: bool) -> impl Iterator<Item = i32> { if flag { (0..3).map(|x| x + 1) } else { vec![10, 20].into_iter() } }