|
|
@ -74,18 +74,15 @@ syntax.
|
|
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
|
|
All examples require the [`"attributes"` feature] to be enabled. This feature
|
|
|
|
|
|
|
|
is not enabled by default because it significantly impacts compile times. See
|
|
|
|
|
|
|
|
[`task::block_on`] for an alternative way to start executing tasks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```rust
|
|
|
|
```rust
|
|
|
|
|
|
|
|
use async_std::task;
|
|
|
|
|
|
|
|
|
|
|
|
async fn say_hello() {
|
|
|
|
async fn say_hello() {
|
|
|
|
println!("Hello, world!");
|
|
|
|
println!("Hello, world!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[async_std::main]
|
|
|
|
fn main() {
|
|
|
|
async fn main() {
|
|
|
|
task::block_on(say_hello())
|
|
|
|
say_hello().await;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|