]>
Commit | Line | Data |
---|---|---|
416331ca XL |
1 | #![feature(type_alias_impl_trait)] |
2 | ||
3 | trait IterBits { | |
4 | type BitsIter: Iterator<Item = u8>; | |
5 | fn iter_bits(self, n: u8) -> Self::BitsIter; | |
6 | } | |
7 | ||
8 | type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>; | |
9 | //~^ ERROR could not find defining uses | |
10 | ||
11 | impl<T, E> IterBits for T | |
12 | where | |
13 | T: std::ops::Shr<Output = T> | |
14 | + std::ops::BitAnd<T, Output = T> | |
15 | + std::convert::From<u8> | |
16 | + std::convert::TryInto<u8, Error = E>, | |
17 | E: std::fmt::Debug, | |
18 | { | |
19 | type BitsIter = IterBitsIter<T, E, u8>; | |
20 | fn iter_bits(self, n: u8) -> Self::BitsIter { | |
60c5eb7d | 21 | //~^ ERROR defining opaque type use does not fully define opaque type |
416331ca XL |
22 | (0u8..n) |
23 | .rev() | |
24 | .map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap()) | |
25 | } | |
26 | } | |
e1599b0c XL |
27 | |
28 | fn main() {} |