mirror of
https://github.com/async-rs/async-std.git
synced 2025-03-01 07:39:40 +00:00
parent
2ef1a762de
commit
fd0b4d4cff
1 changed files with 2 additions and 2 deletions
|
@ -17,7 +17,7 @@ async fn read_file(path: &str) -> Result<String, io::Error> {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let reader_task = task::spawn(async {
|
let reader_task = task::spawn(async {
|
||||||
let result = read_file("data.csv");
|
let result = read_file("data.csv").await;
|
||||||
match result {
|
match result {
|
||||||
Ok(s) => println!("{}", s),
|
Ok(s) => println!("{}", s),
|
||||||
Err(e) => println!("Error reading file: {:?}", e)
|
Err(e) => println!("Error reading file: {:?}", e)
|
||||||
|
@ -33,7 +33,7 @@ This asks the runtime baked into `async_std` to execute the code that reads a fi
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
async {
|
async {
|
||||||
let result = read_file("data.csv");
|
let result = read_file("data.csv").await;
|
||||||
match result {
|
match result {
|
||||||
Ok(s) => println!("{}", s),
|
Ok(s) => println!("{}", s),
|
||||||
Err(e) => println!("Error reading file: {:?}", e)
|
Err(e) => println!("Error reading file: {:?}", e)
|
||||||
|
|
Loading…
Reference in a new issue