From ee3c9f4417c87efb66f9f378bd0261613a42b8a6 Mon Sep 17 00:00:00 2001 From: TechnoPorg Date: Wed, 21 Jan 2026 23:48:12 +0100 Subject: [PATCH] Update non-default feature code --- Cargo.toml | 2 +- src/runner.rs | 2 +- tests/runtimes/async_std.rs | 6 +++--- tests/runtimes/mod.rs | 3 +++ tests/runtimes/smol.rs | 12 +++--------- tests/tracing/with_tracing.rs | 1 + 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1ec4078..1466677 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [ ] } [dependencies] -futures = "0.3" +futures = { version = "0.3", default-features = false, features = ["std"] } parking_lot = "0.12" dagx-macros = { version = "0.3.1", path = "./dagx-macros" } tracing = { version = "0.1", optional = true } diff --git a/src/runner.rs b/src/runner.rs index c3b8d6b..eb3aa7e 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -284,7 +284,7 @@ impl DagRunner { /// # }; /// ``` #[inline] - #[cfg_attr(feature = "tracing", tracing::instrument(skip(self)))] + #[cfg_attr(feature = "tracing", tracing::instrument(skip(self, spawner)))] pub async fn run(&self, spawner: S) -> DagResult<()> where S: Fn(BoxFuture<'static, DagResult<(NodeId, Arc)>>) -> F, diff --git a/tests/runtimes/async_std.rs b/tests/runtimes/async_std.rs index 9e45153..fac48dc 100644 --- a/tests/runtimes/async_std.rs +++ b/tests/runtimes/async_std.rs @@ -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| tokio::spawn(fut).map(Result::unwrap)).await.unwrap(); + dag.run(|fut| async_std::task::spawn(fut)).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| tokio::spawn(fut).map(Result::unwrap)).await.unwrap(); + dag.run(|fut| async_std::task::spawn(fut)).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| tokio::spawn(fut).map(Result::unwrap)).await.unwrap(); + dag.run(|fut| async_std::task::spawn(fut)).await.unwrap(); assert_eq!(dag.get(double).unwrap(), 60); } diff --git a/tests/runtimes/mod.rs b/tests/runtimes/mod.rs index 01c39a8..25bcf9e 100644 --- a/tests/runtimes/mod.rs +++ b/tests/runtimes/mod.rs @@ -2,3 +2,6 @@ pub mod compatibility; pub mod quirky; + +mod async_std; +mod smol; diff --git a/tests/runtimes/smol.rs b/tests/runtimes/smol.rs index 3f41694..d9ad4d1 100644 --- a/tests/runtimes/smol.rs +++ b/tests/runtimes/smol.rs @@ -28,9 +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).map(Result::unwrap)) - .await - .unwrap(); + dag.run(|fut| smol::spawn(fut)).await.unwrap(); assert_eq!(dag.get(sum).unwrap(), 5); }); @@ -45,9 +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).map(Result::unwrap)) - .await - .unwrap(); + dag.run(|fut| smol::spawn(fut)).await.unwrap(); for (i, task) in tasks.iter().enumerate() { assert_eq!(dag.get(task).unwrap(), i * 2); @@ -67,9 +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).map(Result::unwrap)) - .await - .unwrap(); + dag.run(|fut| smol::spawn(fut)).await.unwrap(); assert_eq!(dag.get(double).unwrap(), 60); }); diff --git a/tests/tracing/with_tracing.rs b/tests/tracing/with_tracing.rs index 5690824..69d59cb 100644 --- a/tests/tracing/with_tracing.rs +++ b/tests/tracing/with_tracing.rs @@ -1,6 +1,7 @@ //! Tests with tracing feature enabled use dagx::{task, DagRunner, Task}; +use futures::FutureExt; use tracing_subscriber::{fmt, EnvFilter}; struct Value(i32);