Simplify return type sig

pub struct Index(usize);

pub struct Container {
  data: Vec<T>;
}

impl Container {
  fn enumerate(&self) -> ??? {
    self.data.iter().enumerate().map(|(i, x)| ( Index(i), x ))
  }
}

Now, the generated type is something like Map<Enumerate<Iter<... , but intuitively, I want to use this as a Iter over (Index, T). Is there anyway to express the latter in ??? ? I.e. I only care that it is an Iter that generates (Index, T); I don't care about the detail that it is via Map, Enumerate, Iter.

impl Iterator<Item = (Index, &T)>? Playground.

5 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.