indicator/gat/operator/
identity.rs1use core::marker::PhantomData;
2
3use super::GatOperator;
4
5pub struct Identity<I>(PhantomData<I>);
7
8impl<I> core::fmt::Debug for Identity<I> {
9 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
10 f.debug_tuple("Identity").finish()
11 }
12}
13
14impl<I> Clone for Identity<I> {
15 fn clone(&self) -> Self {
16 *self
17 }
18}
19
20impl<I> Copy for Identity<I> {}
21
22impl<I> Default for Identity<I> {
23 fn default() -> Self {
24 Self(PhantomData)
25 }
26}
27
28impl<I> GatOperator<I> for Identity<I> {
29 type Output<'out> = I
30 where
31 Self: 'out,
32 I: 'out;
33
34 fn next<'out>(&'out mut self, input: I) -> Self::Output<'out>
35 where
36 I: 'out,
37 {
38 input
39 }
40}
41
42pub fn id<I>() -> Identity<I> {
44 Identity(PhantomData)
45}