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 is_source_serialized() -> bool {
56 false
57 }
58
59 fn into_seq_iter(self) -> Self::SequentialIter {
60 core::iter::empty()
61 }
62
63 fn skip_to_end(&self) {}
64
65 fn next(&self) -> Option<Self::Item> {
66 None
67 }
68
69 fn next_with_idx(&self) -> Option<(usize, Self::Item)> {
70 None
71 }
72
73 fn size_hint(&self) -> (usize, Option<usize>) {
74 (0, Some(0))
75 }
76
77 fn is_completed_when_none_returned(&self) -> bool {
78 true
79 }
80
81 fn chunk_puller(&self, chunk_size: usize) -> Self::ChunkPuller<'_> {
82 Self::ChunkPuller::new(self, chunk_size)
83 }
84}
85
86impl<T> ExactSizeConcurrentIter for ConIterEmpty<T>
87where
88 T: Send,
89{
90 fn len(&self) -> usize {
91 0
92 }
93}