From 51d050ebc109a28bcc4d6fca2ddc1ec5e366ac09 Mon Sep 17 00:00:00 2001 From: LukeMathWalker <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 2 Jul 2025 17:27:34 +0200 Subject: [PATCH] Cross-reference the 'Fundamentals' module with the 'Idiomatic Rust' module --- src/idiomatic/leveraging-the-type-system/newtype-pattern.md | 4 ++++ src/user-defined-types/tuple-structs.md | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/idiomatic/leveraging-the-type-system/newtype-pattern.md b/src/idiomatic/leveraging-the-type-system/newtype-pattern.md index e6c04f58..17f5f896 100644 --- a/src/idiomatic/leveraging-the-type-system/newtype-pattern.md +++ b/src/idiomatic/leveraging-the-type-system/newtype-pattern.md @@ -34,6 +34,10 @@ assert_ne!(UserId(1), UserId(2));
+- Students should have encountered the newtype pattern in the "Fundamentals" + course, when they learned about + [tuple structs](../../user-defined-types/tuple-structs.md). + - Run the example to show students the error message from the compiler. - Modify the example to use a typealias instead of a newtype, such as diff --git a/src/user-defined-types/tuple-structs.md b/src/user-defined-types/tuple-structs.md index 53dd2b8f..f2340bf1 100644 --- a/src/user-defined-types/tuple-structs.md +++ b/src/user-defined-types/tuple-structs.md @@ -43,6 +43,8 @@ fn main() { - The value passed some validation when it was created, so you no longer have to validate it again at every use: `PhoneNumber(String)` or `OddNumber(u32)`. +- The newtype pattern is covered extensively in the + ["Idiomatic Rust" module](../idiomatic/leveraging-the-type-system/newtype-pattern.md). - Demonstrate how to add a `f64` value to a `Newtons` type by accessing the single field in the newtype. - Rust generally doesn’t like inexplicit things, like automatic unwrapping or