start of ch17.01

This commit is contained in:
Rowan Torbitzky-Lane 2025-04-01 22:51:17 -05:00
parent 8d9f5104cc
commit 756e74c06a
4 changed files with 44 additions and 0 deletions

16
ch17/async-await.md Normal file
View 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
View 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"

View File

@ -0,0 +1,6 @@
[package]
name = "futures-and-syntax"
version = "0.1.0"
edition = "2021"
[dependencies]

View 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!");
}