midenc-hir 0.8.0

High-level Intermediate Representation for Miden Assembly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub trait IteratorExt {
    /// Returns true if the given iterator consists of exactly one element
    fn has_single_element(&mut self) -> bool;
}

impl<I: Iterator> IteratorExt for I {
    default fn has_single_element(&mut self) -> bool {
        self.next().is_some_and(|_| self.next().is_none())
    }
}

impl<I: ExactSizeIterator> IteratorExt for I {
    #[inline]
    fn has_single_element(&mut self) -> bool {
        self.len() == 1
    }
}