Let's say I have an internal type Walrus, which I can iterate to get Poems. I can imagine implementing this in two different way:
Traits:
impl IntoIterator for Walrus {
type Item = Poem;
...
}
impl<'a> IntoIterator for &'a Walrus {
type Item = &'a Poem;
...
}
Methods:
impl Walrus {
fn iter(&self) -> impl Iterator<Item = &Poem> { ... }
fn into_iter(self) -> impl Iterator<Item = Poem> { ... }
}
Which one is preferable? For a proper library, I'd just do both, as that's what std is doing. However for internal things, I have a strong preference to sticking with only one option.