diff --git a/benches/basic/creation.rs b/benches/basic/creation.rs index 94a8c6b..496b5fd 100644 --- a/benches/basic/creation.rs +++ b/benches/basic/creation.rs @@ -1,7 +1,7 @@ //! DAG creation benchmarks use criterion::Criterion; -use dagx::{DagRunner, Task}; +use dagx::DagRunner; use std::hint::black_box; // Simple task for benchmarking diff --git a/benches/basic/execution.rs b/benches/basic/execution.rs index e7dafcb..15ff351 100644 --- a/benches/basic/execution.rs +++ b/benches/basic/execution.rs @@ -1,7 +1,7 @@ //! Basic DAG execution benchmarks use criterion::Criterion; -use dagx::{task_fn, DagRunner, Task}; +use dagx::{task_fn, DagRunner}; use futures::FutureExt; pub fn bench_dag_execution(c: &mut Criterion) { diff --git a/dagx-macros/src/lib.rs b/dagx-macros/src/lib.rs index a75bab1..23f09fb 100644 --- a/dagx-macros/src/lib.rs +++ b/dagx-macros/src/lib.rs @@ -279,16 +279,7 @@ pub fn task(_attr: TokenStream, item: TokenStream) -> TokenStream { // Extract return type let output_type = match &run_method.sig.output { - ReturnType::Default => { - return syn::Error::new_spanned( - &run_method.sig, - "run() method must have an explicit return type\n\n\ - Specify the output type: async fn run(...) -> OutputType\n\ - For tasks that don't return a value, use '-> ()'.", - ) - .to_compile_error() - .into(); - } + ReturnType::Default => syn::parse_quote!(()), ReturnType::Type(_, ty) => ty.clone(), }; @@ -421,7 +412,7 @@ pub fn task(_attr: TokenStream, item: TokenStream) -> TokenStream { if is_async { // Async with self quote! { - impl Task for #struct_name { + impl ::dagx::Task for #struct_name { type Input = #input_type; type Output = #output_type; @@ -440,7 +431,7 @@ pub fn task(_attr: TokenStream, item: TokenStream) -> TokenStream { } else { // Sync with self - wrap in async block quote! { - impl Task for #struct_name { + impl ::dagx::Task for #struct_name { type Input = #input_type; type Output = #output_type; @@ -462,7 +453,7 @@ pub fn task(_attr: TokenStream, item: TokenStream) -> TokenStream { if is_async { // Async stateless quote! { - impl Task for #struct_name { + impl ::dagx::Task for #struct_name { type Input = #input_type; type Output = #output_type; @@ -482,7 +473,7 @@ pub fn task(_attr: TokenStream, item: TokenStream) -> TokenStream { } else { // Sync stateless quote! { - impl Task for #struct_name { + impl ::dagx::Task for #struct_name { type Input = #input_type; type Output = #output_type; diff --git a/examples/01_basic.rs b/examples/01_basic.rs index 6e9ec5d..4034700 100644 --- a/examples/01_basic.rs +++ b/examples/01_basic.rs @@ -30,7 +30,7 @@ //! Result: 5 //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; // Step 1: Define a source task (no dependencies) diff --git a/examples/02_fan_out.rs b/examples/02_fan_out.rs index d7b9569..2fb6aad 100644 --- a/examples/02_fan_out.rs +++ b/examples/02_fan_out.rs @@ -55,7 +55,7 @@ //! Squared: 100 //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; // Source task with a value field diff --git a/examples/03_fan_in.rs b/examples/03_fan_in.rs index 5390fc5..d5fe8f4 100644 --- a/examples/03_fan_in.rs +++ b/examples/03_fan_in.rs @@ -61,7 +61,7 @@ //! Active: true //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; struct FetchName; diff --git a/examples/circuit_breaker.rs b/examples/circuit_breaker.rs index 23b5d1a..52fcecf 100644 --- a/examples/circuit_breaker.rs +++ b/examples/circuit_breaker.rs @@ -150,7 +150,7 @@ //! Result 7: Ok("Success") //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; use std::sync::Arc; use std::time::Instant; diff --git a/examples/complex_dag.rs b/examples/complex_dag.rs index 5bc4d18..12b071c 100644 --- a/examples/complex_dag.rs +++ b/examples/complex_dag.rs @@ -66,7 +66,7 @@ //! Combined: 6 items, sum=57, avg=9.50 //! ``` -use dagx::{task, DagResult, DagRunner, Task}; +use dagx::{task, DagResult, DagRunner}; use futures::FutureExt; // Extract: Load data from different sources diff --git a/examples/conditional_workflow.rs b/examples/conditional_workflow.rs index 5d719ac..c87151f 100644 --- a/examples/conditional_workflow.rs +++ b/examples/conditional_workflow.rs @@ -55,7 +55,7 @@ //! Expected: Categories: [low, invalid, high] //! ``` -use dagx::{task, DagResult, DagRunner, Task}; +use dagx::{task, DagResult, DagRunner}; use futures::FutureExt; // Task that validates and processes input diff --git a/examples/custom_types.rs b/examples/custom_types.rs index 35f33ed..e8ff188 100644 --- a/examples/custom_types.rs +++ b/examples/custom_types.rs @@ -36,7 +36,7 @@ //! Validation: Alice is valid (age 30 >= 18) //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; // Custom type - just derive Clone! diff --git a/examples/data_pipeline.rs b/examples/data_pipeline.rs index d96798e..afc6187 100644 --- a/examples/data_pipeline.rs +++ b/examples/data_pipeline.rs @@ -75,7 +75,7 @@ //! ============================ //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; // Data source tasks diff --git a/examples/debug_tracing.rs b/examples/debug_tracing.rs index 126a620..cf9a416 100644 --- a/examples/debug_tracing.rs +++ b/examples/debug_tracing.rs @@ -114,7 +114,7 @@ //! FulfillOrder: 30ms //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; use std::time::Instant; use tokio::time::{sleep, Duration}; diff --git a/examples/error_handling.rs b/examples/error_handling.rs index 6b0e272..766c511 100644 --- a/examples/error_handling.rs +++ b/examples/error_handling.rs @@ -114,7 +114,7 @@ //! === Error Handling Example Complete === //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; // Source task that provides a string input diff --git a/examples/large_dag.rs b/examples/large_dag.rs index d0baec5..069caba 100644 --- a/examples/large_dag.rs +++ b/examples/large_dag.rs @@ -109,7 +109,7 @@ //! - Memory overhead is minimal (~ 200 bytes per task) //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; use std::time::Instant; diff --git a/examples/parallelism_proof.rs b/examples/parallelism_proof.rs index 8c62fd2..a9d5ba7 100644 --- a/examples/parallelism_proof.rs +++ b/examples/parallelism_proof.rs @@ -47,7 +47,7 @@ //! This proves TRUE PARALLEL EXECUTION! //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; use std::time::{Duration, Instant}; use tokio::time::sleep; diff --git a/examples/retry_strategies.rs b/examples/retry_strategies.rs index 05d9510..dd6f015 100644 --- a/examples/retry_strategies.rs +++ b/examples/retry_strategies.rs @@ -152,7 +152,7 @@ //! Result: Err("Retry exhausted after 3 attempts: Connection timeout") //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; use tokio::time::{sleep, Duration}; diff --git a/examples/timeout.rs b/examples/timeout.rs index 7f68205..78f8198 100644 --- a/examples/timeout.rs +++ b/examples/timeout.rs @@ -98,7 +98,7 @@ //! === Timeout Example Complete === //! ``` -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; use tokio::time::{sleep, timeout, Duration}; diff --git a/examples/tracing_example.rs b/examples/tracing_example.rs index 30bc713..6eaec33 100644 --- a/examples/tracing_example.rs +++ b/examples/tracing_example.rs @@ -33,7 +33,7 @@ //! - **ERROR**: Errors, panics, cycle detection //! -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; use tracing_subscriber::{fmt, EnvFilter}; diff --git a/src/builder/tests.rs b/src/builder/tests.rs index b6f095e..7aef57f 100644 --- a/src/builder/tests.rs +++ b/src/builder/tests.rs @@ -2,7 +2,6 @@ use crate::builder::IsUnitType; use crate::runner::DagRunner; -use crate::task::Task; use crate::types::TaskHandle; // Initialize tracing subscriber for tests (idempotent) diff --git a/src/deps/tests.rs b/src/deps/tests.rs index c3e40a2..60ae5d0 100644 --- a/src/deps/tests.rs +++ b/src/deps/tests.rs @@ -2,7 +2,6 @@ use crate::deps::DepsTuple; use crate::runner::DagRunner; -use crate::task::Task; use crate::types::{NodeId, TaskHandle}; // Test task for dependency testing diff --git a/src/extract/tests.rs b/src/extract/tests.rs index 2967b61..f8eef37 100644 --- a/src/extract/tests.rs +++ b/src/extract/tests.rs @@ -3,7 +3,6 @@ #![allow(dead_code)] // Test helpers generate unused code via macro use crate::extract::ExtractInput; -use crate::task::Task; use std::any::Any; use std::sync::Arc; diff --git a/src/lib.rs b/src/lib.rs index 492cc60..73b5f83 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -774,6 +774,8 @@ #![allow(private_bounds, private_interfaces)] +extern crate self as dagx; + // Module declarations mod builder; pub mod cycle_prevention; diff --git a/src/node/tests.rs b/src/node/tests.rs index 8f3b351..bc0b25f 100644 --- a/src/node/tests.rs +++ b/src/node/tests.rs @@ -3,7 +3,6 @@ use std::sync::Arc; use crate::node::{ExecutableNode, TypedNode}; -use crate::task::Task; use crate::types::NodeId; // Simple test task diff --git a/src/runner.rs b/src/runner.rs index 20e26a7..1a30457 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -235,7 +235,7 @@ impl DagRunner { /// # Parameters /// /// - `spawner`: A function that spawns futures on the async runtime - /// and returns a handle to the task. This is the only way to run tasks on separate threads. Examples: + /// and returns a handle to the task. This is the only way to run tasks on separate threads. Examples: /// - Tokio: `|fut| { tokio::spawn(fut).map(Result::unwrap) }` /// - Smol: `|fut| { smol::spawn(fut) }` /// - Async-std: `|fut| { async_std::task::spawn(fut) }` @@ -374,7 +374,7 @@ impl DagRunner { let dependencies: Vec<_> = edges[&node_id] .iter() .flat_map(|dep| outputs.get(dep)) - .map(|value| value.clone()) + .cloned() .collect(); // Execute inline with panic handling. @@ -437,7 +437,7 @@ impl DagRunner { let dependencies: Vec<_> = edges[&node_id] .iter() .flat_map(|dep| outputs.get(dep)) - .map(|value| value.clone()) + .cloned() .collect(); // Spawn the task using the provided spawner diff --git a/src/runner/coverage_tests.rs b/src/runner/coverage_tests.rs index 1e6ed6e..c501fe8 100644 --- a/src/runner/coverage_tests.rs +++ b/src/runner/coverage_tests.rs @@ -4,7 +4,6 @@ use crate::error::DagError; use crate::runner::DagRunner; -use crate::task::Task; use crate::types::TaskHandle; use futures::FutureExt; use std::collections::HashMap; diff --git a/src/runner/tests.rs b/src/runner/tests.rs index f48e0d6..51fd191 100644 --- a/src/runner/tests.rs +++ b/src/runner/tests.rs @@ -2,7 +2,6 @@ use crate::error::DagError; use crate::runner::DagRunner; -use crate::task::Task; use crate::types::TaskHandle; use futures::FutureExt; @@ -161,17 +160,11 @@ async fn test_concurrent_run_protection() { assert!(result1.is_ok() != result2.is_ok()); // The error should be about concurrent execution - if result1.is_err() { - assert!(matches!( - result1.unwrap_err(), - crate::error::DagError::ConcurrentExecution - )); + if let Err(e) = result1 { + assert!(matches!(e, crate::error::DagError::ConcurrentExecution)); } - if result2.is_err() { - assert!(matches!( - result2.unwrap_err(), - crate::error::DagError::ConcurrentExecution - )); + if let Err(e) = result2 { + assert!(matches!(e, crate::error::DagError::ConcurrentExecution)); } } diff --git a/src/task/tests.rs b/src/task/tests.rs index 901ded5..86e351d 100644 --- a/src/task/tests.rs +++ b/src/task/tests.rs @@ -167,7 +167,6 @@ async fn test_task_fn_with_option_type() { #[tokio::test] async fn test_task_fn_explicit_trait_call() { // Test explicit Task trait method call to cover line 121 - use crate::task::Task; let task = task_fn(|x: i32| async move { x * 3 }); diff --git a/src/types/coverage_tests.rs b/src/types/coverage_tests.rs index 37f4a67..49ed2e8 100644 --- a/src/types/coverage_tests.rs +++ b/src/types/coverage_tests.rs @@ -2,8 +2,7 @@ //! //! These tests ensure we hit line 71 in the From implementation -use crate::types::TaskHandle; -use crate::{task, DagRunner, Task}; +use crate::{task, DagRunner, TaskHandle}; use futures::FutureExt; #[tokio::test] diff --git a/src/types/tests.rs b/src/types/tests.rs index bf4ce00..2a63044 100644 --- a/src/types/tests.rs +++ b/src/types/tests.rs @@ -1,6 +1,5 @@ //! Unit tests for types module -use crate::task::Task; use crate::types::{NodeId, TaskHandle}; use std::marker::PhantomData; diff --git a/tests/arc_tests.rs b/tests/arc_tests.rs index eb21e24..7ea5420 100644 --- a/tests/arc_tests.rs +++ b/tests/arc_tests.rs @@ -9,7 +9,7 @@ //! //! These tests serve as both validation and documentation for proper Arc usage. -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; use std::collections::{HashMap, HashSet}; use std::sync::Arc; diff --git a/tests/boundaries/zero_tasks.rs b/tests/boundaries/zero_tasks.rs index c745ceb..b43e7c4 100644 --- a/tests/boundaries/zero_tasks.rs +++ b/tests/boundaries/zero_tasks.rs @@ -1,7 +1,7 @@ //! Tests for empty DAGs and minimal task configurations use crate::common::task_fn; -use dagx::{task, DagResult, DagRunner, Task}; +use dagx::{task, DagResult, DagRunner}; use futures::FutureExt; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 8723804..81e2944 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -7,7 +7,7 @@ pub use dagx::task_fn; // Re-export commonly used test structs #[allow(dead_code)] pub mod tasks { - use dagx::{task, Task}; + use dagx::task; // Simple seed task with mutable state pub struct Seed { diff --git a/tests/custom_type_test.rs b/tests/custom_type_test.rs index f953ca5..adc54d1 100644 --- a/tests/custom_type_test.rs +++ b/tests/custom_type_test.rs @@ -1,5 +1,5 @@ // Test that custom types work without any trait implementations -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; #[derive(Clone, Debug, PartialEq)] diff --git a/tests/cycle_prevention.rs b/tests/cycle_prevention.rs index 7aab098..5e71747 100644 --- a/tests/cycle_prevention.rs +++ b/tests/cycle_prevention.rs @@ -3,7 +3,7 @@ //! These tests show that even if you try to create cycles, the Rust compiler //! prevents it through the type-state pattern. -use dagx::{task, DagRunner, Task, TaskHandle}; +use dagx::{task, DagRunner, TaskHandle}; use futures::FutureExt; /// Demonstrates that TaskBuilder is consumed by depends_on, diff --git a/tests/parallelism/timing.rs b/tests/parallelism/timing.rs index 600eba6..c388cc6 100644 --- a/tests/parallelism/timing.rs +++ b/tests/parallelism/timing.rs @@ -1,7 +1,8 @@ //! Tests for timing and speedup verification use crate::common::task_fn; -use dagx::{DagResult, DagRunner, Task}; + +use dagx::{DagResult, DagRunner}; use futures::FutureExt; use std::sync::Arc; use std::sync::Mutex; diff --git a/tests/patterns/grid.rs b/tests/patterns/grid.rs index e15735d..11fdd74 100644 --- a/tests/patterns/grid.rs +++ b/tests/patterns/grid.rs @@ -12,6 +12,7 @@ async fn test_2d_grid_pattern() -> DagResult<()> { let mut grid: Vec>>> = vec![vec![None; 4]; 4]; // Initialize first row and column + #[allow(clippy::needless_range_loop)] for i in 0..4 { let task = dag.add_task(task_fn(move |_: ()| async move { i as i32 })); grid[0][i] = Some((&task).into()); diff --git a/tests/runtimes/async_std.rs b/tests/runtimes/async_std.rs index fac48dc..56b6915 100644 --- a/tests/runtimes/async_std.rs +++ b/tests/runtimes/async_std.rs @@ -1,7 +1,7 @@ //! Runtime compatibility tests for async-std use crate::common::task_fn; -use dagx::{DagRunner, Task}; +use dagx::DagRunner; struct Value(i32); #[dagx::task] @@ -27,7 +27,7 @@ async fn test_basic_dag_async_std() { let y = dag.add_task(Value(3)); let sum = dag.add_task(Add).depends_on((&x, &y)); - dag.run(|fut| async_std::task::spawn(fut)).await.unwrap(); + dag.run(async_std::task::spawn).await.unwrap(); assert_eq!(dag.get(sum).unwrap(), 5); } @@ -40,7 +40,7 @@ async fn test_parallel_execution_async_std() { .map(|i| dag.add_task(task_fn(move |_: ()| async move { i * 2 }))) .collect(); - dag.run(|fut| async_std::task::spawn(fut)).await.unwrap(); + dag.run(async_std::task::spawn).await.unwrap(); for (i, task) in tasks.iter().enumerate() { assert_eq!(dag.get(task).unwrap(), i * 2); @@ -58,7 +58,7 @@ async fn test_complex_dependencies_async_std() { .add_task(task_fn(|x: i32| async move { x * 2 })) .depends_on(sum); - dag.run(|fut| async_std::task::spawn(fut)).await.unwrap(); + dag.run(async_std::task::spawn).await.unwrap(); assert_eq!(dag.get(double).unwrap(), 60); } diff --git a/tests/runtimes/compatibility.rs b/tests/runtimes/compatibility.rs index f77e871..be48b56 100644 --- a/tests/runtimes/compatibility.rs +++ b/tests/runtimes/compatibility.rs @@ -1,6 +1,6 @@ //! Runtime integration tests - verify dagx works correctly across different runtimes -use dagx::{DagResult, DagRunner, Task}; +use dagx::{DagResult, DagRunner}; use futures::FutureExt; struct Value(i32); diff --git a/tests/runtimes/quirky.rs b/tests/runtimes/quirky.rs index 42ef655..6e8f0f4 100644 --- a/tests/runtimes/quirky.rs +++ b/tests/runtimes/quirky.rs @@ -444,8 +444,6 @@ fn test_futures_executor_multi_pool() { #[test] fn test_sync_tasks_on_async_executor() { - use dagx::Task; - struct SyncAdd; #[dagx::task] @@ -473,8 +471,6 @@ fn test_sync_tasks_on_async_executor() { #[test] fn test_sync_tasks_on_pollster() { - use dagx::Task; - struct SyncDouble; #[dagx::task] diff --git a/tests/runtimes/smol.rs b/tests/runtimes/smol.rs index d9ad4d1..5351266 100644 --- a/tests/runtimes/smol.rs +++ b/tests/runtimes/smol.rs @@ -1,7 +1,7 @@ //! Runtime compatibility tests for smol use crate::common::task_fn; -use dagx::{DagRunner, Task}; +use dagx::DagRunner; struct Value(i32); #[dagx::task] @@ -28,7 +28,7 @@ fn test_basic_dag_smol() { let y = dag.add_task(Value(3)); let sum = dag.add_task(Add).depends_on((&x, &y)); - dag.run(|fut| smol::spawn(fut)).await.unwrap(); + dag.run(smol::spawn).await.unwrap(); assert_eq!(dag.get(sum).unwrap(), 5); }); @@ -43,7 +43,7 @@ fn test_parallel_execution_smol() { .map(|i| dag.add_task(task_fn(move |_: ()| async move { i * 2 }))) .collect(); - dag.run(|fut| smol::spawn(fut)).await.unwrap(); + dag.run(smol::spawn).await.unwrap(); for (i, task) in tasks.iter().enumerate() { assert_eq!(dag.get(task).unwrap(), i * 2); @@ -63,7 +63,7 @@ fn test_complex_dependencies_smol() { .add_task(task_fn(|x: i32| async move { x * 2 })) .depends_on(sum); - dag.run(|fut| smol::spawn(fut)).await.unwrap(); + dag.run(smol::spawn).await.unwrap(); assert_eq!(dag.get(double).unwrap(), 60); }); diff --git a/tests/tracing/with_tracing.rs b/tests/tracing/with_tracing.rs index 69d59cb..f6d9d9c 100644 --- a/tests/tracing/with_tracing.rs +++ b/tests/tracing/with_tracing.rs @@ -1,6 +1,6 @@ //! Tests with tracing feature enabled -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; use tracing_subscriber::{fmt, EnvFilter}; diff --git a/tests/tracing/without_tracing.rs b/tests/tracing/without_tracing.rs index 9a8bd8c..79f31b9 100644 --- a/tests/tracing/without_tracing.rs +++ b/tests/tracing/without_tracing.rs @@ -1,6 +1,6 @@ //! Tests that the library works correctly without tracing feature -use dagx::{task, DagRunner, Task}; +use dagx::{task, DagRunner}; use futures::FutureExt; struct Value(i32);