1use std::marker::PhantomData;
2use super::{Instance as Entry, Buf};
3
4pub const fn identity<E>() -> Identity<E> {
5 Identity::SELF
6}
7
8pub trait Instance<In: Entry, Out: Entry> {
9 fn apply<P: super::Ptr>(self, buf: Buf<In, P>) -> Buf<Out, P>;
10}
11
12pub struct Identity<E>(PhantomData<E>);
13
14impl<E> Clone for Identity<E> {
15 fn clone(&self) -> Self {
16 Self::SELF
17 }
18}
19
20impl<E> Copy for Identity<E> {}
21
22impl<E> Identity<E> {
23 pub const SELF: Self = Self(PhantomData);
24}
25
26impl<E: Entry> Instance<E, E> for Identity<E> {
27 fn apply<P: super::Ptr>(self, buf: Buf<E, P>) -> Buf<E, P> {
28 buf
29 }
30}