diff --git a/src/idiomatic/leveraging-the-type-system/newtype-pattern/is-it-encapsulated.md b/src/idiomatic/leveraging-the-type-system/newtype-pattern/is-it-encapsulated.md index 8a8eb1c9..32decb7a 100644 --- a/src/idiomatic/leveraging-the-type-system/newtype-pattern/is-it-encapsulated.md +++ b/src/idiomatic/leveraging-the-type-system/newtype-pattern/is-it-encapsulated.md @@ -4,7 +4,7 @@ minutes: 5 # Is It Truly Encapsulated? -You must evaluate the entire API surface exposed by a newtype to determine if +You must evaluate _the entire API surface_ exposed by a newtype to determine if invariants are indeed bullet-proof. It is crucial to consider all possible interactions, including trait implementations, that may allow users to bypass validation checks. diff --git a/src/idiomatic/leveraging-the-type-system/newtype-pattern/parse-don-t-validate.md b/src/idiomatic/leveraging-the-type-system/newtype-pattern/parse-don-t-validate.md index cc7c0ebf..3989fcae 100644 --- a/src/idiomatic/leveraging-the-type-system/newtype-pattern/parse-don-t-validate.md +++ b/src/idiomatic/leveraging-the-type-system/newtype-pattern/parse-don-t-validate.md @@ -48,14 +48,6 @@ impl Username { underlying value since `&str`, the returned type, restricts them to read-only access. -- Stress the importance of evaluating _the entire API surface_ exposed by a - newtype to determine if invariants are indeed bullet-proof. - - It is crucial to consider all possible interactions, including trait - implementations, that may allow users to bypass the invariants. For example, - if the `Username` type implements the `DerefMut` trait, users can modify the - underlying string directly, bypassing the validation checks in `new`. - - Type-level invariants have second-order benefits. The input is validated once, at the boundary, and the rest of the program can