Skip to content

Commit 7e65a08

Browse files
refactor(variadics): Improvements prepping for release (#974)
- Adds the "spread"/"splat" `...` syntax to the three variadics macros. - Adds `#[sealed]` traits. - Adds testing of error messages. - Improves docs: `README.md` and Rust docs.
1 parent 060de2b commit 7e65a08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1453
-939
lines changed

Cargo.lock

Lines changed: 819 additions & 647 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hydroflow/src/scheduled/handoff/handoff_list.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use ref_cast::RefCast;
44
use sealed::sealed;
5-
use variadics::Variadic;
5+
use variadics::{variadic_trait, Variadic};
66

77
use super::Handoff;
88
use crate::scheduled::graph::HandoffData;
@@ -140,24 +140,17 @@ where
140140
}
141141
}
142142

143-
/// A variadic list of Handoff types, represented using a lisp-style tuple structure.
144-
///
145-
/// This trait is sealed and not meant to be implemented or used directly. Instead tuple lists (which already implement this trait) should be used, for example:
146-
/// ```ignore
147-
/// type MyHandoffList = (VecHandoff<usize>, (VecHandoff<String>, (TeeingHandoff<u32>, ())));
148-
/// ```
149-
/// The [`var_expr!`](variadics::var_expr) macro simplifies usage of this kind:
150-
/// ```ignore
151-
/// type MyHandoffList = var_expr!(VecHandoff<usize>, VecHandoff<String>, TeeingHandoff<u32>);
152-
/// ```
153-
#[sealed]
154-
pub trait HandoffList: Variadic {}
155-
#[sealed]
156-
impl<H, L> HandoffList for (H, L)
157-
where
158-
H: 'static + Handoff,
159-
L: HandoffList,
160-
{
143+
variadic_trait! {
144+
/// A variadic list of Handoff types, represented using a lisp-style tuple structure.
145+
///
146+
/// This trait is sealed and not meant to be implemented or used directly. Instead tuple lists (which already implement this trait) should be used, for example:
147+
/// ```ignore
148+
/// type MyHandoffList = (VecHandoff<usize>, (VecHandoff<String>, (TeeingHandoff<u32>, ())));
149+
/// ```
150+
/// The [`var_expr!`](crate::var) macro simplifies usage of this kind:
151+
/// ```ignore
152+
/// type MyHandoffList = var_expr!(VecHandoff<usize>, VecHandoff<String>, TeeingHandoff<u32>);
153+
/// ```
154+
#[sealed]
155+
pub variadic<T> HandoffList where T: 'static + Handoff {}
161156
}
162-
#[sealed]
163-
impl HandoffList for () {}

hydroflow/tests/compile-fail/surface_demuxenum_notenum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use hydroflow::{hydroflow_syntax, var_args};
1+
use hydroflow::hydroflow_syntax;
22

33
fn main() {
44
struct Shape {

hydroflow/tests/compile-fail/surface_demuxenum_port_duplicate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use hydroflow::util::demux_enum::DemuxEnum;
2-
use hydroflow::{hydroflow_syntax, var_args};
2+
use hydroflow::hydroflow_syntax;
33

44
fn main() {
55
#[derive(DemuxEnum)]

hydroflow/tests/compile-fail/surface_demuxenum_port_duplicate.stderr

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,3 @@ error: Output connection conflicts with above ($DIR/tests/compile-fail/surface_d
99
|
1010
21 | my_demux[Square] -> for_each(std::mem::drop);
1111
| ^^^^^^
12-
13-
warning: unused import: `var_args`
14-
--> tests/compile-fail/surface_demuxenum_port_duplicate.rs:2:35
15-
|
16-
2 | use hydroflow::{hydroflow_syntax, var_args};
17-
| ^^^^^^^^
18-
|
19-
= note: `#[warn(unused_imports)]` on by default

hydroflow/tests/compile-fail/surface_demuxenum_port_elided.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use hydroflow::util::demux_enum::DemuxEnum;
2-
use hydroflow::{hydroflow_syntax, var_args};
2+
use hydroflow::hydroflow_syntax;
33

44
fn main() {
55
#[derive(DemuxEnum)]

hydroflow/tests/compile-fail/surface_demuxenum_port_elided.stderr

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,3 @@ error: Output port from `demux_enum(..)` must be specified and must be a valid i
33
|
44
22 | my_demux -> for_each(std::mem::drop);
55
| ^^^^^^^^
6-
7-
warning: unused import: `var_args`
8-
--> tests/compile-fail/surface_demuxenum_port_elided.rs:2:35
9-
|
10-
2 | use hydroflow::{hydroflow_syntax, var_args};
11-
| ^^^^^^^^
12-
|
13-
= note: `#[warn(unused_imports)]` on by default

hydroflow/tests/compile-fail/surface_demuxenum_port_extra.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use hydroflow::util::demux_enum::DemuxEnum;
2-
use hydroflow::{hydroflow_syntax, var_args};
2+
use hydroflow::hydroflow_syntax;
33

44
fn main() {
55
#[derive(DemuxEnum)]

hydroflow/tests/compile-fail/surface_demuxenum_port_extramissing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use hydroflow::util::demux_enum::DemuxEnum;
2-
use hydroflow::{hydroflow_syntax, var_args};
2+
use hydroflow::hydroflow_syntax;
33

44
fn main() {
55
#[derive(DemuxEnum)]

hydroflow/tests/compile-fail/surface_demuxenum_port_missing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use hydroflow::util::demux_enum::DemuxEnum;
2-
use hydroflow::{hydroflow_syntax, var_args};
2+
use hydroflow::hydroflow_syntax;
33

44
fn main() {
55
#[derive(DemuxEnum)]

0 commit comments

Comments
 (0)