Skip to content

Commit 126ba22

Browse files
authored
Merge pull request #1148 from cwaldren/master
Update new_types.md to clarify conversion to base type
2 parents ffcec6e + 75f61da commit 126ba22

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/generics/new_types.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ fn main() {
4040

4141
Uncomment the last print statement to observe that the type supplied must be `Years`.
4242

43+
To obtain the `newtype`'s value as the base type, you may use tuple 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;
50+
}
51+
```
52+
4353
### See also:
4454

4555
[`structs`][struct]

0 commit comments

Comments
 (0)