Skip to content

Commit c109dab

Browse files
igor-petrukqwandor
andauthored
Update tuple-structs.md (#226)
* 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>
1 parent d1588e4 commit c109dab

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/structs/tuple-structs.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ fn main() {
3131
}
3232
3333
```
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)`.
40+
41+
</details>

0 commit comments

Comments
 (0)