1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#[allow(unused)]
#[derive(Debug)]
pub enum BranchControl {
    Start,
    Continue,
    End,
}

pub trait Controller<T> {
    fn control_branch(&mut self, item: &T) -> BranchControl;
}

impl<T, F> Controller<T> for F
where
    F: FnMut(&T) -> BranchControl,
{
    fn control_branch(&mut self, item: &T) -> BranchControl {
        (self)(item)
    }
}