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
We call this a 'newtype,' because it lets you create a new type that's a synonym for another one
This might cause the reader to think that struct Foo(Bar) creates type Foo, which is a synonym for Bar, and they can be used interchangeably, as with a type alias (or typedef in C).
This is not the case. A newtype declaration creates a distinct type, which cannot be used interchangeably with the type of its underlying representation. I think this should be clarified.
The text was updated successfully, but these errors were encountered:
In http://doc.rust-lang.org/guide.html#tuple-structs-and-newtypes:
This might cause the reader to think that
struct Foo(Bar)
creates typeFoo
, which is a synonym forBar
, and they can be used interchangeably, as with a type alias (or typedef in C).This is not the case. A newtype declaration creates a distinct type, which cannot be used interchangeably with the type of its underlying representation. I think this should be clarified.
The text was updated successfully, but these errors were encountered: