diff --git a/book.toml b/book.toml index 25c67e4b..92d09724 100644 --- a/book.toml +++ b/book.toml @@ -72,6 +72,11 @@ line-numbers = true "unsafe/unsafe-functions.html" = "calling-unsafe-functions.html" "welcome-bare-metal.html" = "bare-metal.html" "welcome-day-4.html" = "concurrency.html" +# Moving exercises between days +"exercises/day-2/luhn.html" = "../day-1/luhn.html" +"exercises/day-2/points-polygons.html" = "../day-3/points-polygons.html" +"exercises/day-1/book-library.html" = "../day-2/book-library.html" +"exercises/day-1/iterators-and-ownership.html" = "../day-2/iterators-and-ownership.html" # Send people to canonical URL instead of index.html "welcome.html" = "./" diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 218f69df..632db31d 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -41,10 +41,43 @@ # Day 1: Afternoon +- [Control Flow](control-flow.md) + - [Blocks](control-flow/blocks.md) + - [if expressions](control-flow/if-expressions.md) + - [for expressions](control-flow/for-expressions.md) + - [while expressions](control-flow/while-expressions.md) + - [break & continue](control-flow/break-continue.md) + - [loop expressions](control-flow/loop-expressions.md) + - [Variables](basic-syntax/variables.md) - [Type Inference](basic-syntax/type-inference.md) - [static & const](basic-syntax/static-and-const.md)) - [Scopes and Shadowing](basic-syntax/scopes-shadowing.md) +- [Enums](enums.md) + - [Variant Payloads](enums/variant-payloads.md) + - [Enum Sizes](enums/sizes.md) + +- [Novel Control Flow](control-flow/novel.md) + - [if let expressions](control-flow/if-let-expressions.md) + - [while let expressions](control-flow/while-let-expressions.md) + - [match expressions](control-flow/match-expressions.md) + +- [Pattern Matching](pattern-matching.md) + - [Destructuring Enums](pattern-matching/destructuring-enums.md) + - [Destructuring Structs](pattern-matching/destructuring-structs.md) + - [Destructuring Arrays](pattern-matching/destructuring-arrays.md) + - [Match Guards](pattern-matching/match-guards.md) + +- [Exercises](exercises/day-1/afternoon.md) + - [Luhn Algorithm](exercises/day-1/luhn.md) + - [Pattern Matching (TBD)]() + +# Day 2: Morning + +---- + +- [Welcome](welcome-day-2.md) + - [Memory Management](memory-management.md) - [Stack vs Heap](memory-management/stack-vs-heap.md) - [Stack Memory](memory-management/stack.md) @@ -64,46 +97,21 @@ - [Lifetimes](ownership/lifetimes.md) - [Lifetimes in Function Calls](ownership/lifetimes-function-calls.md) - [Lifetimes in Data Structures](ownership/lifetimes-data-structures.md) -- [Exercises](exercises/day-1/afternoon.md) - - [Storing Books](exercises/day-1/book-library.md) - - [Iterators and Ownership](exercises/day-1/iterators-and-ownership.md) +- [Exercises](exercises/day-2/morning.md) + - [Storing Books](exercises/day-2/book-library.md) + - [Iterators and Ownership](exercises/day-2/iterators-and-ownership.md) - -# Day 2: Morning - ----- - -- [Welcome](welcome-day-2.md) - [Structs](structs.md) - [Tuple Structs](structs/tuple-structs.md) - [Field Shorthand Syntax](structs/field-shorthand.md) -- [Enums](enums.md) - - [Variant Payloads](enums/variant-payloads.md) - - [Enum Sizes](enums/sizes.md) - [Methods](methods.md) - [Method Receiver](methods/receiver.md) - [Example](methods/example.md) -- [Pattern Matching](pattern-matching.md) - - [Destructuring Enums](pattern-matching/destructuring-enums.md) - - [Destructuring Structs](pattern-matching/destructuring-structs.md) - - [Destructuring Arrays](pattern-matching/destructuring-arrays.md) - - [Match Guards](pattern-matching/match-guards.md) -- [Exercises](exercises/day-2/morning.md) +- [Exercises](exercises/day-2/afternoon.md) - [Health Statistics](exercises/day-2/health-statistics.md) - - [Points and Polygons](exercises/day-2/points-polygons.md) # Day 2: Afternoon -- [Control Flow](control-flow.md) - - [Blocks](control-flow/blocks.md) - - [if expressions](control-flow/if-expressions.md) - - [if let expressions](control-flow/if-let-expressions.md) - - [while expressions](control-flow/while-expressions.md) - - [while let expressions](control-flow/while-let-expressions.md) - - [for expressions](control-flow/for-expressions.md) - - [loop expressions](control-flow/loop-expressions.md) - - [match expressions](control-flow/match-expressions.md) - - [break & continue](control-flow/break-continue.md) - [Standard Library](std.md) - [Option and Result](std/option-result.md) - [String](std/string.md) @@ -119,7 +127,6 @@ - [Paths](modules/paths.md) - [Filesystem Hierarchy](modules/filesystem.md) - [Exercises](exercises/day-2/afternoon.md) - - [Luhn Algorithm](exercises/day-2/luhn.md) - [Strings and Iterators](exercises/day-2/strings-iterators.md) @@ -149,6 +156,7 @@ - [Closures: Fn, FnMut, FnOnce](traits/closures.md) - [Exercises](exercises/day-3/morning.md) - [A Simple GUI Library](exercises/day-3/simple-gui.md) + - [Points and Polygons](exercises/day-3/points-polygons.md) # Day 3: Afternoon diff --git a/src/control-flow/novel.md b/src/control-flow/novel.md new file mode 100644 index 00000000..9205e76b --- /dev/null +++ b/src/control-flow/novel.md @@ -0,0 +1,8 @@ +# Novel Control Flow + +Rust has a few control flow constructs which differ from other languages. They +are used for pattern matching: + +- `if let` expressions +- `while let` expressions +- `match` expressions diff --git a/src/exercises/Cargo.toml b/src/exercises/Cargo.toml index 72c3e58c..41d61d04 100644 --- a/src/exercises/Cargo.toml +++ b/src/exercises/Cargo.toml @@ -8,30 +8,30 @@ publish = false name = "for-loops" path = "day-1/for-loops.rs" -[[bin]] -name = "book-library" -path = "day-1/book-library.rs" - -[[bin]] -name = "points-polygons" -path = "day-2/points-polygons.rs" - [[bin]] name = "luhn" -path = "day-2/luhn.rs" +path = "day-1/luhn.rs" + +[[bin]] +name = "book-library" +path = "day-2/book-library.rs" [[bin]] name = "strings-iterators" path = "day-2/strings-iterators.rs" -[[bin]] -name = "safe-ffi-wrapper" -path = "day-3/safe-ffi-wrapper.rs" - [[bin]] name = "simple-gui" path = "day-3/simple-gui.rs" +[[bin]] +name = "points-polygons" +path = "day-3/points-polygons.rs" + +[[bin]] +name = "safe-ffi-wrapper" +path = "day-3/safe-ffi-wrapper.rs" + [[bin]] name = "dining-philosophers" path = "concurrency/dining-philosophers.rs" diff --git a/src/exercises/day-1/afternoon.md b/src/exercises/day-1/afternoon.md index f194e2d3..31e2f66e 100644 --- a/src/exercises/day-1/afternoon.md +++ b/src/exercises/day-1/afternoon.md @@ -2,9 +2,9 @@ We will look at two things: -* A small book library, +* The Luhn algorithm, -* Iterators and ownership (hard). +* An exercise on pattern matching.
diff --git a/src/exercises/day-2/luhn.md b/src/exercises/day-1/luhn.md similarity index 100% rename from src/exercises/day-2/luhn.md rename to src/exercises/day-1/luhn.md diff --git a/src/exercises/day-2/luhn.rs b/src/exercises/day-1/luhn.rs similarity index 100% rename from src/exercises/day-2/luhn.rs rename to src/exercises/day-1/luhn.rs diff --git a/src/exercises/day-1/solutions-afternoon.md b/src/exercises/day-1/solutions-afternoon.md index 42366aeb..c8bff12c 100644 --- a/src/exercises/day-1/solutions-afternoon.md +++ b/src/exercises/day-1/solutions-afternoon.md @@ -1,9 +1,13 @@ # Day 1 Afternoon Exercises -## Designing a Library +## Luhn Algorithm -([back to exercise](book-library.md)) +([back to exercise](luhn.md)) ```rust -{{#include book-library.rs}} +{{#include luhn.rs}} ``` + +## Pattern matching + +TBD. diff --git a/src/exercises/day-1/book-library.md b/src/exercises/day-2/book-library.md similarity index 100% rename from src/exercises/day-1/book-library.md rename to src/exercises/day-2/book-library.md diff --git a/src/exercises/day-1/book-library.rs b/src/exercises/day-2/book-library.rs similarity index 100% rename from src/exercises/day-1/book-library.rs rename to src/exercises/day-2/book-library.rs diff --git a/src/exercises/day-1/iterators-and-ownership.md b/src/exercises/day-2/iterators-and-ownership.md similarity index 100% rename from src/exercises/day-1/iterators-and-ownership.md rename to src/exercises/day-2/iterators-and-ownership.md diff --git a/src/exercises/day-2/solutions-afternoon.md b/src/exercises/day-2/solutions-afternoon.md index bf9601bd..45c10529 100644 --- a/src/exercises/day-2/solutions-afternoon.md +++ b/src/exercises/day-2/solutions-afternoon.md @@ -1,13 +1,5 @@ # Day 2 Afternoon Exercises -## Luhn Algorithm - -([back to exercise](luhn.md)) - -```rust -{{#include luhn.rs}} -``` - ## Strings and Iterators ([back to exercise](strings-iterators.md)) diff --git a/src/exercises/day-2/solutions-morning.md b/src/exercises/day-2/solutions-morning.md index 6f765b99..a62cd4a3 100644 --- a/src/exercises/day-2/solutions-morning.md +++ b/src/exercises/day-2/solutions-morning.md @@ -1,9 +1,9 @@ # Day 2 Morning Exercises -## Points and Polygons +## Designing a Library -([back to exercise](points-polygons.md)) +([back to exercise](book-library.md)) ```rust -{{#include points-polygons.rs}} +{{#include book-library.rs}} ``` diff --git a/src/exercises/day-3/morning.md b/src/exercises/day-3/morning.md index d6a19da2..974ec153 100644 --- a/src/exercises/day-3/morning.md +++ b/src/exercises/day-3/morning.md @@ -1,6 +1,8 @@ # Day 3: Morning Exercises -We will design a classical GUI library traits and trait objects. +We will design a classical GUI library using traits and trait objects. + +We will also look at enum dispatch with an exercise involving points and polygons.
diff --git a/src/exercises/day-2/points-polygons.md b/src/exercises/day-3/points-polygons.md similarity index 100% rename from src/exercises/day-2/points-polygons.md rename to src/exercises/day-3/points-polygons.md diff --git a/src/exercises/day-2/points-polygons.rs b/src/exercises/day-3/points-polygons.rs similarity index 100% rename from src/exercises/day-2/points-polygons.rs rename to src/exercises/day-3/points-polygons.rs diff --git a/src/exercises/day-3/solutions-morning.md b/src/exercises/day-3/solutions-morning.md index 069b0eeb..df80c3cf 100644 --- a/src/exercises/day-3/solutions-morning.md +++ b/src/exercises/day-3/solutions-morning.md @@ -7,3 +7,11 @@ ```rust {{#include simple-gui.rs}} ``` + +## Points and Polygons + +([back to exercise](points-polygons.md)) + +```rust +{{#include points-polygons.rs}} +``` diff --git a/src/running-the-course/course-structure.md b/src/running-the-course/course-structure.md index fe44905f..627e4675 100644 --- a/src/running-the-course/course-structure.md +++ b/src/running-the-course/course-structure.md @@ -4,9 +4,9 @@ The course is fast paced and covers a lot of ground: -* Day 1: Basic Rust, ownership and the borrow checker. -* Day 2: Compound data types, pattern matching, the standard library. -* Day 3: Traits and generics, error handling, testing, unsafe Rust. +* Day 1: Basic Rust, syntax, control flow, creating and consuming values. +* Day 2: Memory management, ownership, compound data types, and the standard library. +* Day 3: Generics, traits, error handling, testing, and unsafe Rust. ## Deep Dives diff --git a/src/welcome-day-1.md b/src/welcome-day-1.md index 48607df4..39cea21b 100644 --- a/src/welcome-day-1.md +++ b/src/welcome-day-1.md @@ -6,10 +6,10 @@ today: * Basic Rust syntax: variables, scalar and compound types, enums, structs, references, functions, and methods. -* Memory management: stack vs heap, manual memory management, scope-based memory - management, and garbage collection. +* Control flow constructs: `if`, `if let`, `while`, `while let`, `break`, and + `continue`. -* Ownership: move semantics, copying and cloning, borrowing, and lifetimes. +* Pattern matching: destructuring enums, structs, and arrays.
diff --git a/src/welcome-day-2.md b/src/welcome-day-2.md index 62b48fc3..a86e6dbe 100644 --- a/src/welcome-day-2.md +++ b/src/welcome-day-2.md @@ -2,12 +2,12 @@ Now that we have seen a fair amount of Rust, we will continue with: -* Structs, enums, methods. +* Memory management: stack vs heap, manual memory management, scope-based memory + management, and garbage collection. -* Pattern matching: destructuring enums, structs, and arrays. +* Ownership: move semantics, copying and cloning, borrowing, and lifetimes. -* Control flow constructs: `if`, `if let`, `while`, `while let`, `break`, and - `continue`. +* Structs and methods. * The Standard Library: `String`, `Option` and `Result`, `Vec`, `HashMap`, `Rc` and `Arc`.