orx_concurrent_iter/copied/
chunk_puller.rs1use crate::pullers::ChunkPuller;
2use core::iter::Copied;
3
4pub struct CopiedChunkPuller<'i, T, P>
8where
9 T: Copy + 'i,
10 P: ChunkPuller<ChunkItem = &'i T>,
11{
12 puller: P,
13}
14
15impl<'i, T, P> From<P> for CopiedChunkPuller<'i, T, P>
16where
17 T: Copy + 'i,
18 P: ChunkPuller<ChunkItem = &'i T>,
19{
20 fn from(puller: P) -> Self {
21 Self { puller }
22 }
23}
24
25impl<'i, T, P> ChunkPuller for CopiedChunkPuller<'i, T, P>
26where
27 T: Copy + 'i,
28 P: ChunkPuller<ChunkItem = &'i T>,
29{
30 type ChunkItem = T;
31
32 type Chunk<'c>
33 = Copied<P::Chunk<'c>>
34 where
35 Self: 'c;
36
37 fn chunk_size(&self) -> usize {
38 self.puller.chunk_size()
39 }
40
41 fn pull(&mut self) -> Option<Self::Chunk<'_>> {
42 self.puller.pull().map(|x| x.copied())
43 }
44
45 fn pull_with_idx(&mut self) -> Option<(usize, Self::Chunk<'_>)> {
46 self.puller
47 .pull_with_idx()
48 .map(|(begin_idx, x)| (begin_idx, x.copied()))
49 }
50}