Skip to content

Commit

Permalink
fix compile warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrielC committed Jan 14, 2025
1 parent 6298ce6 commit 90fcd80
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions rig-core/src/pipeline/conditional.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use futures::{join, try_join};

Check warning on line 1 in rig-core/src/pipeline/conditional.rs

View workflow job for this annotation

GitHub Actions / stable / fmt

Diff in /home/runner/work/rig/rig/rig-core/src/pipeline/conditional.rs
use super::{Op, TryOp};
/// Creates an `Op` that conditionally dispatches to one of multiple sub-ops
/// based on the variant of the input enum.
///
Expand Down Expand Up @@ -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<Value, Out, $( $variant ),+> crate::pipeline::Op for ConditionalOp<$($variant),+>
impl<Value, Out, $($variant),+> Op for ConditionalOp<$($variant),+>
where
$( $variant: crate::pipeline::Op<Input=Value, Output=Out> ),+,
$($variant: Op<Input=Value, Output=Out>),+,
Value: Send + Sync,
Out: Send + Sync,
{
Expand Down Expand Up @@ -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<Value, Out, Err, $( $variant ),+> crate::pipeline::TryOp for TryConditionalOp<$( $variant ),+>
impl<Value, Out, Err, $( $variant ),+> TryOp for TryConditionalOp<$( $variant ),+>
where
$( $variant: crate::pipeline::TryOp<Input=Value, Output=Out, Error=Err> ),+,
$( $variant: TryOp<Input=Value, Output=Out, Error=Err> ),+,
Value: Send + Sync,
Out: Send + Sync,
Err: Send + Sync,
Expand All @@ -139,7 +141,6 @@ macro_rules! try_conditional {

#[cfg(test)]
mod tests {
use super::*;
use crate::pipeline::*;

Check warning on line 145 in rig-core/src/pipeline/conditional.rs

View workflow job for this annotation

GitHub Actions / stable / fmt

Diff in /home/runner/work/rig/rig/rig-core/src/pipeline/conditional.rs
#[tokio::test]
Expand All @@ -152,7 +153,7 @@ mod tests {

Check warning on line 153 in rig-core/src/pipeline/conditional.rs

View workflow job for this annotation

GitHub Actions / stable / fmt

Diff in /home/runner/work/rig/rig/rig-core/src/pipeline/conditional.rs
let op1 = map(|x: i32| x + 1);
let op2 = map(|x: i32| x * 2);

let conditional =
conditional!(ExampleEnum,
Variant1 => op1,
Expand All @@ -168,6 +169,7 @@ mod tests {

Check warning on line 169 in rig-core/src/pipeline/conditional.rs

View workflow job for this annotation

GitHub Actions / stable / fmt

Diff in /home/runner/work/rig/rig/rig-core/src/pipeline/conditional.rs
#[tokio::test]
async fn test_try_conditional_op() {

enum ExampleEnum<T> {
Variant1(T),
Variant2(T)
Expand Down

0 comments on commit 90fcd80

Please sign in to comment.