Skip to content

Commit 51d050e

Browse files
Cross-reference the 'Fundamentals' module with the 'Idiomatic Rust' module
1 parent edfe9e8 commit 51d050e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/idiomatic/leveraging-the-type-system/newtype-pattern.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ assert_ne!(UserId(1), UserId(2));
3434

3535
<details>
3636

37+
- Students should have encountered the newtype pattern in the "Fundamentals"
38+
course, when they learned about
39+
[tuple structs](../../user-defined-types/tuple-structs.md).
40+
3741
- Run the example to show students the error message from the compiler.
3842

3943
- Modify the example to use a typealias instead of a newtype, such as

src/user-defined-types/tuple-structs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ fn main() {
4343
- The value passed some validation when it was created, so you no longer have
4444
to validate it again at every use: `PhoneNumber(String)` or
4545
`OddNumber(u32)`.
46+
- The newtype pattern is covered extensively in the
47+
["Idiomatic Rust" module](../idiomatic/leveraging-the-type-system/newtype-pattern.md).
4648
- Demonstrate how to add a `f64` value to a `Newtons` type by accessing the
4749
single field in the newtype.
4850
- Rust generally doesn’t like inexplicit things, like automatic unwrapping or

0 commit comments

Comments
 (0)