You probably noticed, but it should become a thing in RFC 3591: https://github.com/rust-lang/rust/issues/134691
So it does kind of work on current nightly:
#![feature(import_trait_associated_functions)] use std::iter::Iterator::{filter, map, collect}; fn get_ids2(data: Vec<Widget>) -> Vec<Id> { collect(map(filter(Vec::into_iter(data), |w| w.alive), |w| w.id)) } fn get_ids3(data: impl Iterator<Item = Widget>) -> Vec<Id> { collect(map(filter(data, |w| w.alive), |w| w.id)) }
You probably noticed, but it should become a thing in RFC 3591: https://github.com/rust-lang/rust/issues/134691
So it does kind of work on current nightly: