diff --git a/rig-core/src/pipeline/conditional.rs b/rig-core/src/pipeline/conditional.rs index 546365a9..3b9ce767 100644 --- a/rig-core/src/pipeline/conditional.rs +++ b/rig-core/src/pipeline/conditional.rs @@ -1,6 +1,4 @@ -use futures::{join, try_join}; -use super::{Op, TryOp}; /// Creates an `Op` that conditionally dispatches to one of multiple sub-ops /// based on the variant of the input enum. /// @@ -40,13 +38,16 @@ use super::{Op, TryOp}; macro_rules! conditional { ($enum:ident, $( $variant:ident => $op:expr ),+ $(,)?) => { { + #[allow(non_snake_case)] struct ConditionalOp<$($variant),+> { - $( $variant: $variant ),+ + $( + $variant: $variant, + )+ } - impl crate::pipeline::Op for ConditionalOp<$($variant),+> + impl Op for ConditionalOp<$($variant),+> where - $( $variant: crate::pipeline::Op ),+, + $($variant: Op),+, Value: Send + Sync, Out: Send + Sync, { @@ -108,13 +109,14 @@ macro_rules! conditional { macro_rules! try_conditional { ($enum:ident, $( $variant:ident => $op:expr ),+ $(,)?) => { { + #[allow(non_snake_case)] struct TryConditionalOp<$( $variant ),+> { $( $variant: $variant ),+ } - impl crate::pipeline::TryOp for TryConditionalOp<$( $variant ),+> + impl TryOp for TryConditionalOp<$( $variant ),+> where - $( $variant: crate::pipeline::TryOp ),+, + $( $variant: TryOp ),+, Value: Send + Sync, Out: Send + Sync, Err: Send + Sync, @@ -139,7 +141,6 @@ macro_rules! try_conditional { #[cfg(test)] mod tests { - use super::*; use crate::pipeline::*; #[tokio::test] @@ -152,7 +153,7 @@ mod tests { let op1 = map(|x: i32| x + 1); let op2 = map(|x: i32| x * 2); - + let conditional = conditional!(ExampleEnum, Variant1 => op1, @@ -168,6 +169,7 @@ mod tests { #[tokio::test] async fn test_try_conditional_op() { + enum ExampleEnum { Variant1(T), Variant2(T)