Can't send message to self
Here is some example code:
import std::stdio::STDOUT
import std::process::(sleep)
import std::time::(Duration, Instant)
class async Main {
fn print_step(message: String) {
STDOUT.new.print(message)
sleep(Duration.from_secs(1))
}
fn async loop {
while true {
self.print_step('hello world!')
self.print_step('hello world!')
}
}
fn async main {
let main = Main{}
async main.loop
}
}
This code works.
However, if I add async
to print_step
, then the program abort at run-time.
I don't understand why this limitation is in place.