1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::vec::IntoIter;

use pulldown_cmark::Event;

use crate::link::Link;

#[derive(Debug)]
pub enum Aggregation<'a> {
    Event(Event<'a>),
    Bag(Vec<Event<'a>>),
    Link(Link<'a>),
}

impl<'a> IntoIterator for Aggregation<'a> {
    type Item = Event<'a>;

    type IntoIter = IntoIter<Event<'a>>;

    fn into_iter(self) -> Self::IntoIter {
        match self {
            Aggregation::Event(e) => vec![e].into_iter(),
            Aggregation::Bag(vec) => vec.into_iter(),
            Aggregation::Link(l) => l.into_iter(),
        }
    }
}