Function interval_func
Source pub fn interval_func<C, F>(
scope: &mut Scope<'_, C>,
interval: Duration,
fun: F,
) -> Response<IntervalFunc<C>, Void>
Expand description
A helper function to create intervals from closures
20fn create_pair<C>(scope: &mut Scope<C>)
21 -> Response<(IntervalFunc<C>, Dummy), Void>
22{
23 interval_func(scope, Duration::new(1, 0), |_| {
24 println!("Second passed");
25 }).wrap(|fsm| (fsm, Dummy))
26}
More examples
Hide additional examples
10fn main() {
11 let loop_creator = Loop::new(&Config::new()).unwrap();
12 let mut loop_inst = loop_creator.instantiate(());
13 loop_inst.add_machine_with(|scope| {
14 interval_func(scope, Duration::new(1, 0), |_| {
15 println!("Second passed");
16 })
17 }).unwrap();
18 loop_inst.run().unwrap();
19}