macro_rules! when {
( $junction:ident; $initial_channel:ident, $( $other_channels:ident ),* ) => { ... };
}
Expand description
An alternate syntax for defining Join Pattern channel constrains.
The when
macro allows for a number of channels to be defined
using a list like syntax, opposed to the standard method chaining
provided by the default Public API of Rusty
Junctions.
§Example
§Standard API
By using the standard Public API we can define our computation using the following syntax.
let junction = rusty_junctions::Junction::new();
let chan1 = junction.send_channel::<i32>();
let chan2 = junction.send_channel::<i32>();
let chan3 = junction.send_channel::<i32>();
junction.when(&chan1)
.and(&chan2)
.and(&chan3)
.then_do(|v1, v2, v3| println!("{v1}, {v2}, {v3}"))
§when
Macro API
However, it is also possible to use this richer more expressive syntax, when creating the firing conditions for a Join Pattern.
let junction = rusty_junctions::Junction::new();
let chan1 = junction.send_channel::<i32>();
let chan2 = junction.send_channel::<i32>();
let chan3 = junction.send_channel::<i32>();
when!(junction; chan1, chan2, chan3)
.then_do(|v1, v2, v3| println!("{v1}, {v2}, {v3}"))