orx_concurrent_iter/implementations/empty/
con_iter.rs1use super::chunk_puller::ChunkPullerEmpty;
2use crate::{ConcurrentIter, exact_size_concurrent_iter::ExactSizeConcurrentIter};
3use core::marker::PhantomData;
4
5#[derive(Debug, Clone, Copy)]
21pub struct ConIterEmpty<T> {
22 phantom: PhantomData<T>,
23}
24
25unsafe impl<T> Sync for ConIterEmpty<T> {}
26
27impl<T> Default for ConIterEmpty<T> {
28 fn default() -> Self {
29 Self::new()
30 }
31}
32
33impl<T> ConIterEmpty<T> {
34 pub fn new() -> Self {
36 Self {
37 phantom: PhantomData,
38 }
39 }
40}
41
42impl<T> ConcurrentIter for ConIterEmpty<T>
43where
44 T: Send,
45{
46 type Item = T;
47
48 type SequentialIter = core::iter::Empty<T>;
49
50 type ChunkPuller<'i>
51 = ChunkPullerEmpty<'i, T>
52 where
53 Self: 'i;
54
55 fn into_seq_iter(self) -> Self::SequentialIter {
56 core::iter::empty()
57 }
58
59 fn skip_to_end(&self) {}
60
61 fn next(&self) -> Option<Self::Item> {
62 None
63 }
64
65 fn next_with_idx(&self) -> Option<(usize, Self::Item)> {
66 None
67 }
68
69 fn size_hint(&self) -> (usize, Option<usize>) {
70 (0, Some(0))
71 }
72
73 fn chunk_puller(&self, chunk_size: usize) -> Self::ChunkPuller<'_> {
74 Self::ChunkPuller::new(self, chunk_size)
75 }
76}
77
78impl<T> ExactSizeConcurrentIter for ConIterEmpty<T>
79where
80 T: Send,
81{
82 fn len(&self) -> usize {
83 0
84 }
85}