chore: clean up in preparation for release

This commit is contained in:
TechnoPorg committed 2026-02-18 22:34:31 +01:00
1 parent c002161216
commit 827041c1b6
28 files changed
+112 -219

No files matched your search

-9
View File
@@ -212,13 +212,6 @@ impl<T> Clone for TaskHandle<T> {
impl<T> Copy for TaskHandle<T> {}
// TaskHandle can be converted from &TaskHandle (for .get() calls)
impl<T> From<&TaskHandle<T>> for TaskHandle<T> {
fn from(handle: &TaskHandle<T>) -> Self {
*handle
}
}
/// Takes a task and converts it to either a TaskBuilder or a TaskHandle,
/// depending on whether it has inputs or not.
///
@@ -269,8 +262,6 @@ macro_rules! impl_wire_tuple {
};
}
// Generate DepsTuple implementations for tuples of size 2-8.
// Supporting up to 8 elements covers the vast majority of use cases.
impl_wire_tuple!(T1);
impl_wire_tuple!(T1, T2);
impl_wire_tuple!(T1, T2, T3);
+9 -21
View File
@@ -21,21 +21,9 @@ impl DepsTuple<()> for () {
}
// Implementation for single dependency (all forms)
impl<T, O> DepsTuple<(O,)> for T
where
T: Into<TaskHandle<O>>,
{
impl<O> DepsTuple<(O,)> for TaskHandle<O> {
fn to_node_ids(self) -> Vec<NodeId> {
vec![self.into().id]
}
}
impl<T, O> DepsTuple<O> for (T,)
where
T: Into<TaskHandle<O>>,
{
fn to_node_ids(self) -> Vec<NodeId> {
vec![self.0.into().id]
vec![self.id]
}
}
@@ -47,27 +35,27 @@ where
/// This allows flexible dependency specification:
/// ```ignore
/// // Using handles
/// task.depends_on((&handle_a, &handle_b))
/// task.depends_on((handle_a, handle_b))
///
/// // Using builders directly
/// task.depends_on((&dag.add_task(TaskA), &dag.add_task(TaskB)))
/// task.depends_on((dag.add_task(TaskA), dag.add_task(TaskB)))
/// ```
macro_rules! impl_deps_tuple {
($($T:ident : $O:ident),+) => {
// For tuples of any combination of &TaskHandle, TaskHandle, and TaskBuilder
impl<$($T: Into<TaskHandle<$O>>, $O),+> DepsTuple<($($O,)+)> for ($($T,)+)
impl<$($O),+> DepsTuple<($($O,)+)> for ($(TaskHandle<$O>,)+)
{
#[allow(non_snake_case)]
fn to_node_ids(self) -> Vec<NodeId> {
let ($($T,)+) = self;
vec![$($T.into().id,)+]
let ($($O,)+) = self;
vec![$($O.id,)+]
}
}
};
}
// Generate DepsTuple implementations for tuples of size 2-8.
// Generate DepsTuple implementations for tuples of size 1-8.
// Supporting up to 8 elements covers the vast majority of use cases.
impl_deps_tuple!(T1:O1);
impl_deps_tuple!(T1:O1, T2:O2);
impl_deps_tuple!(T1:O1, T2:O2, T3:O3);
impl_deps_tuple!(T1:O1, T2:O2, T3:O3, T4:O4);
+6 -28
View File
@@ -57,7 +57,7 @@ fn test_deps_tuple_single_handle_tuple_ref() {
id: NodeId(7),
_phantom: std::marker::PhantomData,
};
let node_ids = (&handle,).to_node_ids();
let node_ids = (handle,).to_node_ids();
assert_eq!(node_ids.len(), 1);
assert_eq!(node_ids[0], NodeId(7));
}
@@ -114,7 +114,7 @@ fn test_deps_tuple_multiple_handles() {
};
// Test 2-tuple
let node_ids = (&handle1, &handle2).to_node_ids();
let node_ids = (handle1, handle2).to_node_ids();
assert_eq!(node_ids.len(), 2);
assert_eq!(node_ids[0], NodeId(1));
assert_eq!(node_ids[1], NodeId(2));
@@ -124,7 +124,7 @@ fn test_deps_tuple_multiple_handles() {
id: NodeId(3),
_phantom: std::marker::PhantomData,
};
let node_ids = (&handle1, &handle2, &handle3).to_node_ids();
let node_ids = (handle1, handle2, handle3).to_node_ids();
assert_eq!(node_ids.len(), 3);
assert_eq!(node_ids[0], NodeId(1));
assert_eq!(node_ids[1], NodeId(2));
@@ -162,7 +162,7 @@ fn test_deps_tuple_large_tuples() {
}
// Test 4-tuple
let node_ids = (&handles[0], &handles[1], &handles[2], &handles[3]).to_node_ids();
let node_ids = (handles[0], handles[1], handles[2], handles[3]).to_node_ids();
assert_eq!(node_ids.len(), 4);
for (i, node_id) in node_ids.iter().enumerate().take(4) {
assert_eq!(*node_id, NodeId(i as u32));
@@ -170,14 +170,8 @@ fn test_deps_tuple_large_tuples() {
// Test 8-tuple
let node_ids = (
&handles[0],
&handles[1],
&handles[2],
&handles[3],
&handles[4],
&handles[5],
&handles[6],
&handles[7],
handles[0], handles[1], handles[2], handles[3], handles[4], handles[5], handles[6],
handles[7],
)
.to_node_ids();
assert_eq!(node_ids.len(), 8);
@@ -185,19 +179,3 @@ fn test_deps_tuple_large_tuples() {
assert_eq!(*node_id, NodeId(i as u32));
}
}
#[test]
fn test_deps_handle_ref_explicit() {
// Test explicit &TaskHandle DepsTuple impl (line 27-28 in deps.rs)
let handle: TaskHandle<i32> = TaskHandle {
id: NodeId(77),
_phantom: std::marker::PhantomData,
};
// Create a reference and explicitly call to_node_ids
let handle_ref = &handle;
let node_ids = DepsTuple::<(i32,)>::to_node_ids(handle_ref);
assert_eq!(node_ids.len(), 1);
assert_eq!(node_ids[0], NodeId(77));
}
+6 -5
View File
@@ -320,8 +320,8 @@
//! let mut dag = DagRunner::new();
//!
//! let base = dag.add_task(Value(10)).into();
//! let plus1 = dag.add_task(Add(1)).depends_on(&base);
//! let times2 = dag.add_task(Scale(2)).depends_on(&base);
//! let plus1 = dag.add_task(Add(1)).depends_on(base);
//! let times2 = dag.add_task(Scale(2)).depends_on(base);
//!
//!let mut output = dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() }).await.unwrap();
//!
@@ -656,9 +656,9 @@
//! let data = dag.add_task(FetchData).into();
//!
//! // All three tasks get efficient Arc-wrapped sharing automatically
//! let task1 = dag.add_task(ProcessData).depends_on(&data);
//! let task2 = dag.add_task(ProcessData).depends_on(&data);
//! let task3 = dag.add_task(ProcessData).depends_on(&data);
//! let task1 = dag.add_task(ProcessData).depends_on(data);
//! let task2 = dag.add_task(ProcessData).depends_on(data);
//! let task3 = dag.add_task(ProcessData).depends_on(data);
//!
//!let mut output = dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() }).await.unwrap();
//! # };
@@ -784,4 +784,5 @@ pub use runner::DagRunner;
pub use task::{Task, TaskInput};
// Re-export the procedural macro
#[cfg(feature = "derive")]
pub use dagx_macros::task;
+1 -4
View File
@@ -51,10 +51,7 @@ impl DagOutput {
/// assert_eq!(output.get(task).unwrap(), 42);
/// # };
/// ```
pub fn get<T: 'static + Send + Sync, H>(&mut self, handle: H) -> DagResult<T>
where
H: Into<TaskHandle<T>>,
{
pub fn get<T: 'static + Send + Sync>(&mut self, handle: TaskHandle<T>) -> DagResult<T> {
let handle: TaskHandle<T> = handle.into();
let arc_output = self
+6 -6
View File
@@ -460,13 +460,13 @@ impl DagRunner {
}
}
}
}
// Return first error if any
if let Some(err) = first_error {
#[cfg(feature = "tracing")]
error!(?err, "DAG execution failed");
return Err(err);
// Return first error if any
if let Some(err) = first_error {
#[cfg(feature = "tracing")]
error!(?err, "DAG execution failed");
return Err(err);
}
}
#[cfg(feature = "tracing")]
-9
View File
@@ -140,14 +140,5 @@ impl_task_input!(A, B, C, D, E, F);
impl_task_input!(A, B, C, D, E, F, G);
impl_task_input!(A, B, C, D, E, F, G, H);
impl TaskInput<'static, ()> {
pub fn empty() -> Self {
Self {
inputs: [].iter(),
phantom: PhantomData,
}
}
}
#[cfg(test)]
mod tests;
-6
View File
@@ -32,9 +32,3 @@ async fn test_custom_task_implementation() {
// Can't call run again since task was consumed
// This demonstrates the ownership model
}
#[test]
fn test_empty_task_input() {
let empty = TaskInput::empty();
assert_eq!(empty.inputs.len(), 0);
}