We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9ce6bf9 + a48ec1d commit 134914bCopy full SHA for 134914b
src/generics/new_types.md
@@ -40,13 +40,14 @@ fn main() {
40
41
Uncomment the last print statement to observe that the type supplied must be `Years`.
42
43
-To obtain the `newtype`'s value as the base type, you may use tuple syntax like so:
+To obtain the `newtype`'s value as the base type, you may use the tuple or destructuring syntax like so:
44
```rust, editable
45
struct Years(i64);
46
47
fn main() {
48
let years = Years(42);
49
- let years_as_primitive: i64 = years.0;
+ let years_as_primitive_1: i64 = years.0; // Tuple
50
+ let Years(years_as_primitive_2) = years; // Destructuring
51
}
52
```
53
0 commit comments