1use crate::Pin;
7
8#[rustfmt::skip]
12pub struct Pinned<A, B = (), C = (), D = (), E = (), F = (), G = (), H = ()> {
13 a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H
14}
15
16#[rustfmt::skip]
17mod impls {
18 use super::{Pin, Pinned};
19
20 impl<A> Pinned<A> {
21 pub fn from_a(a: A) -> Self {
23 Pinned { a, b: (), c: (), d: (), e: (), f: (), g: (), h: () }
24 }
25 pub fn with_b<B>(self, b: B) -> Pinned<A, B> {
27 Pinned { a: self.a,
28 b, c: (), d: (), e: (), f: (), g: (), h: ()
29 }
30 }
31 }
32 impl<A, B> Pinned<A, B> {
33 pub fn with_c<C>(self, c: C) -> Pinned<A, B, C> {
35 Pinned {
36 a: self.a, b: self.b,
37 c, d: (), e: (), f: (), g: (), h: ()
38 }
39 }
40 }
41 impl<A, B, C> Pinned<A, B, C> {
42 pub fn with_d<D>(self, d: D) -> Pinned<A, B, C, D> {
44 Pinned {
45 a: self.a, b: self.b, c: self.c,
46 d, e: (), f: (), g: (), h: (),
47 }
48 }
49 }
50 impl<A, B, C, D> Pinned<A, B, C, D> {
51 pub fn with_e<E>(self, e: E) -> Pinned<A, B, C, D, E> {
53 Pinned {
54 a: self.a, b: self.b, c: self.c, d: self.d,
55 e, f: (), g: (), h: ()
56 }
57 }
58 }
59 impl<A, B, C, D, E> Pinned<A, B, C, D, E> {
60 pub fn with_f<F>(self, f: F) -> Pinned<A, B, C, D, E, F> {
62 Pinned {
63 a: self.a, b: self.b, c: self.c, d: self.d, e: self.e,
64 f, g: (), h: (),
65 }
66 }
67 }
68 impl<A, B, C, D, E, F> Pinned<A, B, C, D, E, F> {
69 pub fn with_g<G>(self, g: G) -> Pinned<A, B, C, D, E, F, G> {
71 Pinned {
72 a: self.a, b: self.b, c: self.c, d: self.d, e: self.e, f: self.f,
73 g, h: (),
74 }
75 }
76 }
77 impl<A, B, C, D, E, F, G> Pinned<A, B, C, D, E, F, G> {
78 pub fn with_h<H>(self, h: H) -> Pinned<A, B, C, D, E, F, G, H> {
80 Pinned {
81 a: self.a, b: self.b, c: self.c, d: self.d, e: self.e, f: self.f, g: self.g,
82 h,
83 }
84 }
85 }
86
87 impl<A, B, C, D, E, F, G, H> Pinned<A, B, C, D, E, F, G, H> {
89 pub fn a(self: Pin<&mut Self>) -> Pin<&mut A> {
91 unsafe { self.map_unchecked_mut(|this| &mut this.a) }
93 }
94 pub fn b(self: Pin<&mut Self>) -> Pin<&mut B> {
96 unsafe { self.map_unchecked_mut(|this| &mut this.b) }
98 }
99 pub fn c(self: Pin<&mut Self>) -> Pin<&mut C> {
101 unsafe { self.map_unchecked_mut(|this| &mut this.c) }
103 }
104 pub fn d(self: Pin<&mut Self>) -> Pin<&mut D> {
106 unsafe { self.map_unchecked_mut(|this| &mut this.d) }
108 }
109 pub fn e(self: Pin<&mut Self>) -> Pin<&mut E> {
111 unsafe { self.map_unchecked_mut(|this| &mut this.e) }
113 }
114 pub fn f(self: Pin<&mut Self>) -> Pin<&mut F> {
116 unsafe { self.map_unchecked_mut(|this| &mut this.f) }
118 }
119 pub fn g(self: Pin<&mut Self>) -> Pin<&mut G> {
121 unsafe { self.map_unchecked_mut(|this| &mut this.g) }
123 }
124 pub fn h(self: Pin<&mut Self>) -> Pin<&mut H> {
126 unsafe { self.map_unchecked_mut(|this| &mut this.h) }
128 }
129 }
130}