summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui/components/navigation/navigation_find.rs
blob: 79c8ab0f8a56c571be6bec49798c9a4b236b72d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
impl<'a, TOption> super::Navigation<TOption>
where
    TOption: Clone + PartialEq + 'a,
{
    pub fn find<P>(&self, pred: P) -> Option<TOption>
    where
        P: Fn(&TOption) -> bool,
    {
        self.options_before_active
            .iter()
            .find(|o| pred(o))
            .cloned()
            .or_else(|| self.active_option.clone().filter(|o| pred(o)))
            .or_else(|| self.options_after_active.iter().find(|o| pred(o)).cloned())
    }
}