Lifting of n-ary functions.
A lift maps a function on values to a function on signals. Given a function of
F: Fn(A, B, …) -> R and signals of types
Signal<A>, Signal<B>, … the
lift! macro creates a
Signal<R>, whose content is computed using the
Currently lift is only implemented for functions with up to four arguments. This limitation is due to the current implementation strategy (and maybe limitations of Rust's type system), but it can be increased to arbitrary but finite arity if required.
let sink_a = Sink::new(); let sink_b = Sink::new(); let product = lift!( |a, b| a * b, &sink_a.stream().hold(0), &sink_b.stream().hold(0) ); assert_eq!(product.sample(), 0); sink_a.send(3); sink_b.send(5); assert_eq!(product.sample(), 15);
Lift a 0-ary function.
Lift a unary function.
Lift a binary function.
Lift a ternary function.
Lift a quarternary function.