-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d45e42
commit 150648c
Showing
23 changed files
with
558 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
mod option; | ||
mod poll; | ||
mod result; | ||
mod tuples; | ||
mod vec; | ||
|
||
/// An output Kind where T is a generic type and some of the parameters are borrows. | ||
#[doc(hidden)] | ||
pub struct Deep<T>(core::marker::PhantomData<T>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
use crate::output::*; | ||
|
||
type Mix<K> = Deep<Option<K>>; | ||
|
||
impl<K: Kind> Kind for Mix<K> { | ||
type Return = AsReturn<K>; | ||
type Respond = AsRespond<K>; | ||
} | ||
|
||
impl<K> Return for Mix<K> | ||
where | ||
K: Return, | ||
<K as Return>::Type: 'static + Send + Sync, | ||
{ | ||
type Type = Option<<K as Return>::Type>; | ||
} | ||
|
||
impl<T, K: Return> IntoReturnOnce<Mix<K>> for Option<T> | ||
where | ||
<K as Return>::Type: 'static + Send + Sync, | ||
T: IntoReturnOnce<K>, | ||
{ | ||
fn into_return_once(self) -> ResponderResult<AsReturn<K>> { | ||
match self { | ||
Some(val) => Ok(AsReturn::Some(val.into_return_once()?)), | ||
None => Ok(AsReturn::None), | ||
} | ||
} | ||
} | ||
|
||
impl<T, K: Return> IntoReturn<Mix<K>> for Option<T> | ||
where | ||
<K as Return>::Type: 'static + Send + Sync, | ||
T: IntoReturn<K>, | ||
{ | ||
fn into_return(self) -> ResponderResult<AsReturn<K>> { | ||
match self { | ||
Some(val) => Ok(AsReturn::Some(val.into_return()?)), | ||
None => Ok(AsReturn::None), | ||
} | ||
} | ||
} | ||
|
||
impl<T, K: Kind> IntoRespond<Mix<K>> for Option<T> | ||
where | ||
T: IntoRespond<K>, | ||
{ | ||
fn into_respond(self) -> ResponderResult<AsRespond<K>> { | ||
match self { | ||
Some(val) => Ok(AsRespond::Some(val.into_respond()?)), | ||
None => Ok(AsRespond::None), | ||
} | ||
} | ||
} | ||
|
||
pub enum AsReturn<K: Kind> { | ||
Some(K::Return), | ||
None, | ||
} | ||
|
||
impl<K: Kind> GetOutput for AsReturn<K> | ||
where | ||
Self: 'static, | ||
{ | ||
type Output<'u> = | ||
Option< | ||
<<K as Kind>::Return as GetOutput>::Output<'u>, | ||
> | ||
where | ||
Self: 'u; | ||
|
||
fn output(&self) -> Option<Self::Output<'_>> { | ||
match self { | ||
Self::Some(val) => Some(Some(val.output()?)), | ||
Self::None => Some(None), | ||
} | ||
} | ||
} | ||
|
||
pub enum AsRespond<K: Kind> { | ||
Some(K::Respond), | ||
None, | ||
} | ||
|
||
impl<K: Kind> IntoOutput for AsRespond<K> | ||
where | ||
Self: 'static, | ||
{ | ||
type Output<'u> = | ||
Option< | ||
<<K as Kind>::Respond as IntoOutput>::Output<'u>, | ||
> | ||
where | ||
Self: 'u; | ||
|
||
fn into_output<'u>(self, value_chain: &'u ValueChain) -> Self::Output<'u> { | ||
match self { | ||
Self::Some(val) => Some(val.into_output(value_chain)), | ||
Self::None => None, | ||
} | ||
} | ||
} |
Oops, something went wrong.