enum Command { Task1, Task2, } struct Peripheral; async fn dispatch(command: Command) { let mut peri: Peripheral; loop { peri = match command { Command::Task1 => task1(peri).await, Command::Task2 => task1(peri).await, } } } async fn task1(peri: Peripheral) -> Peripheral {} async fn task2(peri: Peripheral) -> Peripheral {}