mirror of https://github.com/0xplaygrounds/rig
Update try_op.rs
This commit is contained in:
parent
af884299aa
commit
59540fbb90
|
@ -345,33 +345,35 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement TryParallel
|
// Implement TryParallel
|
||||||
// pub struct TryParallel<Op1, Op2> {
|
pub struct TryParallel<Op1, Op2> {
|
||||||
// op1: Op1,
|
op1: Op1,
|
||||||
// op2: Op2,
|
op2: Op2,
|
||||||
// }
|
}
|
||||||
|
|
||||||
// impl<Op1, Op2> TryParallel<Op1, Op2> {
|
impl<Op1, Op2> TryParallel<Op1, Op2> {
|
||||||
// pub fn new(op1: Op1, op2: Op2) -> Self {
|
pub fn new(op1: Op1, op2: Op2) -> Self {
|
||||||
// Self { op1, op2 }
|
Self { op1, op2 }
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// impl<Op1, Op2> TryOp for TryParallel<Op1, Op2>
|
impl<Op1, Op2> op::Op for TryParallel<Op1, Op2>
|
||||||
// where
|
where
|
||||||
// Op1: TryOp,
|
Op1: TryOp,
|
||||||
// Op2: TryOp<Input = Op1::Input, Output = Op1::Output, Error = Op1::Error>,
|
Op2: TryOp<Input = Op1::Input, Error = Op1::Error>,
|
||||||
// {
|
{
|
||||||
// type Input = Op1::Input;
|
type Input = Op1::Input;
|
||||||
// type Output = (Op1::Output, Op2::Output);
|
type Output = Result<(Op1::Output, Op2::Output), Op1::Error>;
|
||||||
// type Error = Op1::Error;
|
|
||||||
|
|
||||||
// #[inline]
|
#[inline]
|
||||||
// async fn try_call(&self, input: Self::Input) -> Result<Self::Output, Self::Error> {
|
async fn try_call(&self, input: Self::Input) -> Result<(Op1::Output, Op2::Output), Op1::Error> {
|
||||||
// let (output1, output2) = tokio::join!(self.op1.try_call(input.clone()), self.op2.try_call(input));
|
use futures::try_join;
|
||||||
// Ok((output1?, output2?))
|
try_join!(
|
||||||
// }
|
self.op1.try_call(input.clone()),
|
||||||
// }
|
self.op2.try_call(input)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
Loading…
Reference in New Issue