#![feature(type_alias_impl_trait)] trait IterBits { type BitsIter: Iterator; fn iter_bits(self, n: u8) -> Self::BitsIter; } type IterBitsIter = impl std::iter::Iterator; impl IterBits for T where T: std::ops::Shr + std::ops::BitAnd + std::convert::From + std::convert::TryInto, E: std::fmt::Debug, { type BitsIter = IterBitsIter; fn iter_bits(self, n: u8) -> Self::BitsIter { (0u8..n).rev().map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap()) //~^ ERROR non-defining opaque type use in defining scope } } fn main() {}