From 756e74c06a391548735edbc5818234837c36d2b2 Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Tue, 1 Apr 2025 22:51:17 -0500 Subject: [PATCH] start of ch17.01 --- ch17/async-await.md | 16 ++++++++++++++++ ch17/futures-and-syntax/Cargo.lock | 7 +++++++ ch17/futures-and-syntax/Cargo.toml | 6 ++++++ ch17/futures-and-syntax/src/main.rs | 15 +++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 ch17/async-await.md create mode 100644 ch17/futures-and-syntax/Cargo.lock create mode 100644 ch17/futures-and-syntax/Cargo.toml create mode 100644 ch17/futures-and-syntax/src/main.rs diff --git a/ch17/async-await.md b/ch17/async-await.md new file mode 100644 index 0000000..19def8d --- /dev/null +++ b/ch17/async-await.md @@ -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. diff --git a/ch17/futures-and-syntax/Cargo.lock b/ch17/futures-and-syntax/Cargo.lock new file mode 100644 index 0000000..2c34df9 --- /dev/null +++ b/ch17/futures-and-syntax/Cargo.lock @@ -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" diff --git a/ch17/futures-and-syntax/Cargo.toml b/ch17/futures-and-syntax/Cargo.toml new file mode 100644 index 0000000..1920010 --- /dev/null +++ b/ch17/futures-and-syntax/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "futures-and-syntax" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/ch17/futures-and-syntax/src/main.rs b/ch17/futures-and-syntax/src/main.rs new file mode 100644 index 0000000..27796b7 --- /dev/null +++ b/ch17/futures-and-syntax/src/main.rs @@ -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!"); +}