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