2 ms·
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 p
by aliceryhl 6y ago
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.