In this example, NoGood
is pub, and AtomWord
is private.
I'd like to export an instance of IntoIterator
, but I can't because this huge type definition for IntoIter
includes a reference to AtomWord
.
I realize I could create an Iterator
wrapper that just passes calls through to the underlying iterator, but that's a lot of boilerplate. I can't think of any way to make the wrapper class generic (without defeating the purpose, which is to hide the AtomWord
type).
impl <'a> IntoIterator for &'a NoGood {
type Item = Literal;
type IntoIter = FilterMap<slice::Iter<'a, AtomWord>, fn(&AtomWord) -> Option<Literal>>;
fn into_iter(self) -> Self::IntoIter {
(&self.lits).into_iter().filter_map(as_opt_lit)
}
}