orx_concurrent_recursive_iter/
sized.rs

1trait Seal {}
2
3/// Marker trait determining whether the iterator is exact-sized or not.
4#[allow(private_bounds)]
5pub trait Size: Seal + Send + Sync + Clone + Copy {
6    /// Returns the total number of elements that the recursive iterator
7    /// will generate if completely consumed.
8    ///
9    /// Returns None if this is not known ahead of time.
10    fn exact_len(self) -> Option<usize>;
11}
12
13/// The iterator has known exact size.
14#[derive(Clone, Copy)]
15pub struct ExactSize(pub(super) usize);
16impl Seal for ExactSize {}
17impl Size for ExactSize {
18    #[inline(always)]
19    fn exact_len(self) -> Option<usize> {
20        Some(self.0)
21    }
22}
23
24/// Size of the iterator is unknown ahead of time.
25#[derive(Clone, Copy)]
26pub struct UnknownSize;
27impl Seal for UnknownSize {}
28impl Size for UnknownSize {
29    #[inline(always)]
30    fn exact_len(self) -> Option<usize> {
31        None
32    }
33}