You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update tuple-structs.md
I am adding more information about newtypes. The speaker can get questions about it or may wish to encourage this great pattern.
* Fix typos and explanation
Co-authored-by: Andrew Walbran <qwandor@google.com>
Copy file name to clipboardExpand all lines: src/structs/tuple-structs.md
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -31,3 +31,11 @@ fn main() {
31
31
}
32
32
33
33
```
34
+
35
+
<details>
36
+
37
+
Newtypes are a great way to encode additional information about the value in a primitive type, for example:
38
+
* The number is measured in some units: `Newtons` in the example above.
39
+
* 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)`.
0 commit comments