orx_parallel/infallible/fun/map/
cloned_copied.rs1use crate::infallible::fun::Map;
2use core::marker::PhantomData;
3
4pub struct FnCloned<'a, I: Clone>(PhantomData<&'a I>);
8
9impl<'a, I: Clone> Clone for FnCloned<'a, I> {
10 fn clone(&self) -> Self {
11 *self
12 }
13}
14
15impl<'a, I: Clone> Copy for FnCloned<'a, I> {}
16
17unsafe impl<'a, I: Clone> Send for FnCloned<'a, I> {}
18
19impl<'a, I: Clone> FnCloned<'a, I> {
20 pub fn new() -> Self {
22 Self(PhantomData)
23 }
24}
25
26impl<'a, I: Clone> Default for FnCloned<'a, I> {
27 fn default() -> Self {
28 Self::new()
29 }
30}
31
32impl<'a, I: Clone> Map for FnCloned<'a, I> {
33 type I = &'a I;
34
35 type O = I;
36
37 #[inline(always)]
38 fn map(&self, i: Self::I) -> Self::O {
39 i.clone()
40 }
41}
42
43pub struct FnCopied<'a, I: Copy>(PhantomData<&'a I>);
47
48impl<'a, I: Copy> Clone for FnCopied<'a, I> {
49 fn clone(&self) -> Self {
50 *self
51 }
52}
53
54impl<'a, I: Copy> Copy for FnCopied<'a, I> {}
55
56unsafe impl<'a, I: Copy> Send for FnCopied<'a, I> {}
57
58impl<'a, I: Copy> FnCopied<'a, I> {
59 pub fn new() -> Self {
61 Self(PhantomData)
62 }
63}
64
65impl<'a, I: Copy> Default for FnCopied<'a, I> {
66 fn default() -> Self {
67 Self::new()
68 }
69}
70
71impl<'a, I: Copy> Map for FnCopied<'a, I> {
72 type I = &'a I;
73
74 type O = I;
75
76 #[inline(always)]
77 fn map(&self, i: Self::I) -> Self::O {
78 *i
79 }
80}