Re:Names are not type safety
by aliceryhl on Monday November 02, 2020 @11:48AM
(#24970092)
The point of a newtype is that it allows you to create a wrapper around some other type for one of the following two purposes:
1. Marking the kind of data to prevent mixing up values of different kinds. (e.g. Email)
2. Outlawing some of the values of the underlying type. (e.g. OneToFive)
I do not think it being a tuple-struct or not is important at all when deciding whether something uses the newtype pattern, as long as it has a single field.
1. Marking the kind of data to prevent mixing up values of different kinds. (e.g. Email)
2. Outlawing some of the values of the underlying type. (e.g. OneToFive)
I do not think it being a tuple-struct or not is important at all when deciding whether something uses the newtype pattern, as long as it has a single field.