macro_rules! task {
($closure:expr) => { ... };
(Low, $closure:expr) => { ... };
(Normal, $closure:expr) => { ... };
(High, $closure:expr) => { ... };
($name:literal, $closure:expr) => { ... };
(Low, $name:literal, $closure:expr) => { ... };
(Normal, $name:literal, $closure:expr) => { ... };
(High, $name:literal, $closure:expr) => { ... };
($name:literal, Low, $closure:expr) => { ... };
($name:literal, Normal, $closure:expr) => { ... };
($name:literal, High, $closure:expr) => { ... };
($priority:expr, $closure:expr) => { ... };
($name:expr, $priority:expr, $closure:expr) => { ... };
}Expand description
Macro for creating tasks with less boilerplate
§Examples
ⓘ
// Minimal - anonymous task with Normal priority
let task = task!(|ctx| {
// task body
Ok(())
});
// With name only (Normal priority)
let task = task!("my_task", |ctx| {
// task body
Ok(())
});
// With name and priority
let task = task!("my_task", High, |ctx| {
// task body
Ok(())
});
// With priority only (anonymous task)
let task = task!(Low, |ctx| {
// task body
Ok(())
});
// With move semantics (works with all patterns)
let captured = 42;
let task = task!("my_task", move |ctx| {
println!("Captured: {}", captured);
Ok(())
});