#![doc = include_str!("../examples/noalloc.rs")]
#![doc = include_str!("../examples/simple.rs")]
#![no_std]
use core::pin::Pin;
pub struct Sp<A, B = (), C = (), D = (), E = (), F = (), G = (), H = ()> {
a: A,
b: B,
c: C,
d: D,
e: E,
f: F,
g: G,
h: H,
}
impl<A> Sp<A> {
pub fn from_a(a: A) -> Self {
Sp {
a,
b: (),
c: (),
d: (),
e: (),
f: (),
g: (),
h: (),
}
}
pub fn with_b<B>(self, b: B) -> Sp<A, B> {
Sp {
a: self.a,
b,
c: (),
d: (),
e: (),
f: (),
g: (),
h: (),
}
}
}
impl<A, B> Sp<A, B> {
pub fn with_c<C>(self, c: C) -> Sp<A, B, C> {
Sp {
a: self.a,
b: self.b,
c,
d: (),
e: (),
f: (),
g: (),
h: (),
}
}
}
impl<A, B, C> Sp<A, B, C> {
pub fn with_d<D>(self, d: D) -> Sp<A, B, C, D> {
Sp {
a: self.a,
b: self.b,
c: self.c,
d,
e: (),
f: (),
g: (),
h: (),
}
}
}
impl<A, B, C, D> Sp<A, B, C, D> {
pub fn with_e<E>(self, e: E) -> Sp<A, B, C, D, E> {
Sp {
a: self.a,
b: self.b,
c: self.c,
d: self.d,
e,
f: (),
g: (),
h: (),
}
}
}
impl<A, B, C, D, E> Sp<A, B, C, D, E> {
pub fn with_f<F>(self, f: F) -> Sp<A, B, C, D, E, F> {
Sp {
a: self.a,
b: self.b,
c: self.c,
d: self.d,
e: self.e,
f,
g: (),
h: (),
}
}
}
impl<A, B, C, D, E, F> Sp<A, B, C, D, E, F> {
pub fn with_g<G>(self, g: G) -> Sp<A, B, C, D, E, F, G> {
Sp {
a: self.a,
b: self.b,
c: self.c,
d: self.d,
e: self.e,
f: self.f,
g,
h: (),
}
}
}
impl<A, B, C, D, E, F, G> Sp<A, B, C, D, E, F, G> {
pub fn with_h<H>(self, h: H) -> Sp<A, B, C, D, E, F, G, H> {
Sp {
a: self.a,
b: self.b,
c: self.c,
d: self.d,
e: self.e,
f: self.f,
g: self.g,
h,
}
}
}
impl<A, B, C, D, E, F, G, H> Sp<A, B, C, D, E, F, G, H> {
pub fn a(self: Pin<&mut Self>) -> Pin<&mut A> {
unsafe { self.map_unchecked_mut(|this| &mut this.a) }
}
pub fn b(self: Pin<&mut Self>) -> Pin<&mut B> {
unsafe { self.map_unchecked_mut(|this| &mut this.b) }
}
pub fn c(self: Pin<&mut Self>) -> Pin<&mut C> {
unsafe { self.map_unchecked_mut(|this| &mut this.c) }
}
pub fn d(self: Pin<&mut Self>) -> Pin<&mut D> {
unsafe { self.map_unchecked_mut(|this| &mut this.d) }
}
pub fn e(self: Pin<&mut Self>) -> Pin<&mut E> {
unsafe { self.map_unchecked_mut(|this| &mut this.e) }
}
pub fn f(self: Pin<&mut Self>) -> Pin<&mut F> {
unsafe { self.map_unchecked_mut(|this| &mut this.f) }
}
pub fn g(self: Pin<&mut Self>) -> Pin<&mut G> {
unsafe { self.map_unchecked_mut(|this| &mut this.g) }
}
pub fn h(self: Pin<&mut Self>) -> Pin<&mut H> {
unsafe { self.map_unchecked_mut(|this| &mut this.h) }
}
}