1#[macro_export]
6macro_rules! get {
7 (fn($input:ident: &mut $ity:ty) -> $oty:ty { $($v:tt)+ }) => {{
8 $crate::get!(fn<'a>($input: &mut $ity) -> $oty {$($v)+})
9 }};
10 (fn<$a:lifetime>($input:ident: &mut $ity:ty) -> $oty:ty { $($v:tt)+ }) => {{
11 #[derive(Clone, Copy)]
12 struct Impl;
13 impl $crate::GetFut for Impl {
14 type Input = $ity;
15 type Output = $oty;
16 fn get_fut<$a>(self, $input: &$a mut Self::Input) -> impl $a+Future<Output = Self::Output> {
17 $($v)+
18 }
19 }
20 Impl
21 }};
22}
23
24#[macro_export]
29macro_rules! try_get {
30 (fn($input:ident: &mut $ity:ty) -> Result<($oty:ty, $aty:ty), $ety:ty> { $($v:tt)+ }) => {{
31 $crate::try_get!(fn<'a>($input: &mut $ity) -> Result<($oty, $aty), $ety> {$($v)+})
32 }};
33 (fn<$a:lifetime>($input:ident: &mut $ity:ty) -> Result<($oty:ty, $aty:ty), $ety:ty> { $($v:tt)+ }) => {{
34 #[derive(Clone, Copy)]
35 struct Impl;
36 impl $crate::TryGetFut for Impl {
37 type Input = $ity;
38 type Output = $oty;
39 type Aux = $aty;
40 type Error = $ety;
41 fn try_get_fut<$a>(self, $input: &$a mut Self::Input) -> Result<(impl $a+Future<Output = Self::Output>, Self::Aux), Self::Error> {
42 $($v)+
43 }
44 }
45 Impl
46 }};
47}
48
49#[cfg(feature = "async")]
54#[macro_export]
55macro_rules! async_try_get {
56 (async fn($input:ident: &mut $ity:ty) -> Result<($oty:ty, $aty:ty), $ety:ty> { $($v:tt)+ }) => {{
57 $crate::async_try_get!(async fn<'a, 'b>($input: &mut $ity) -> Result<($oty, $aty), $ety> {$($v)+})
58 }};
59 (async fn<$a:lifetime, $b:lifetime>($input:ident: &mut $ity:ty) -> Result<($oty:ty, $aty:ty), $ety:ty> { $($v:tt)+ }) => {{
60 #[derive(Clone, Copy)]
61 struct Impl;
62 impl<$a> $crate::AsyncTryGetFut<$a> for Impl {
63 type Input = $ity;
64 type Output = $oty;
65 type Aux = $aty;
66 type Error = $ety;
67 async fn async_try_get_fut<$b>(self, $input: &$b mut Self::Input) -> Result<(impl $b+Future<Output = Self::Output>, Self::Aux), Self::Error> {
68
69 $($v)+
70 }
71 }
72 Impl
73 }};
74}
75#[cfg(feature = "async")]
84#[macro_export]
85macro_rules! async_send_try_get {
86 (fn($input:ident: &mut $ity:ty) -> Result<($oty:ty, $aty:ty), $ety:ty> { $($v:tt)+ }) => {{
87 $crate::async_send_try_get!(fn<'a, 'b>($input: &mut $ity) -> Result<($oty, $aty), $ety> {$($v)+})
88 }};
89 (fn<$a:lifetime, $b:lifetime>($input:ident: &mut $ity:ty) -> Result<($oty:ty, $aty:ty), $ety:ty> { $($v:tt)+ }) => {{
90
91 use alloc::boxed::Box;
92 use core::pin::Pin;
93
94 #[derive(Clone, Copy)]
95 struct Impl;
96 impl<$a> $crate::AsyncSendTryGetFut<$a> for Impl {
97 type Input = $ity;
98 type Output = $oty;
99 type Aux = $aty;
100 type Error = $ety;
101 fn async_send_try_get_fut<$b>(self, $input: &$b mut Self::Input) -> Pin<Box<dyn $b + Send + Future<Output = Result<(Pin<Box<dyn $b + Send + Future<Output = Self::Output>>>, Self::Aux), Self::Error>>>> {
102 Box::pin({$($v)+})
103 }
104 }
105 Impl
106 }};
107}