start of ch17.01
This commit is contained in:
parent
8d9f5104cc
commit
756e74c06a
16
ch17/async-await.md
Normal file
16
ch17/async-await.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Async and Await Notes
|
||||||
|
|
||||||
|
```rust
|
||||||
|
let data = fetch_data_from(url).await;
|
||||||
|
println!("{data}");
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parallelism and Concurrency
|
||||||
|
|
||||||
|
*Concurrency*: When an individual works on several different
|
||||||
|
tasks before any of them is complete. When get bored with one
|
||||||
|
project, just switch to another task.
|
||||||
|
|
||||||
|
*Parallelism*: Split up a group of tasks between the people on
|
||||||
|
the team with each person taking one task and working
|
||||||
|
on it alone.
|
7
ch17/futures-and-syntax/Cargo.lock
generated
Normal file
7
ch17/futures-and-syntax/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-and-syntax"
|
||||||
|
version = "0.1.0"
|
6
ch17/futures-and-syntax/Cargo.toml
Normal file
6
ch17/futures-and-syntax/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "futures-and-syntax"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
15
ch17/futures-and-syntax/src/main.rs
Normal file
15
ch17/futures-and-syntax/src/main.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//! Futures and the Async Syntax
|
||||||
|
//!
|
||||||
|
//! Key elements of async are *futures*, `async`, and `await`.
|
||||||
|
//! A *future* is a value which may not be ready now, but will
|
||||||
|
//! be ready at some point in the future.
|
||||||
|
//!
|
||||||
|
//! The `async` keyword can be applied to blocks and functions
|
||||||
|
//! to specify they can be interrupted and resumed.
|
||||||
|
//!
|
||||||
|
//! Stopped here:
|
||||||
|
//! https://rust-book.cs.brown.edu/ch17-01-futures-and-syntax.html#futures-and-the-async-syntax
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user