Async/await runs things concurrently by repeatedly swapping out the currently running task, however such swapping can only happen at an .await
. Since learn_song
and sing_song
have no .await
, no such swapping of current task can happen while they run.
This is also why you should never sleep using thread::sleep
. Rust is not able to let some other task run while it is sleeping because there is no .await
.
Check out this example: playground. Additionally try increasing the loop in dancing
to run 20 times.