From bbd0631fe46ee61ba4a62f8e24b8603ef357f63e Mon Sep 17 00:00:00 2001 From: LukeMathWalker <20745048+LukeMathWalker@users.noreply.github.com> Date: Mon, 7 Jul 2025 16:05:34 +0200 Subject: [PATCH] Avoid incorrect attribution to the borrow-checker --- .../newtype-pattern/parse-don-t-validate.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 d5bdfc4a..cc7c0ebf 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 @@ -44,8 +44,9 @@ impl Username { ensuring that all instances of `Username` satisfy those checks. - The `as_str` method allows consumers to access the raw string representation - (e.g., to store it in a database) but, thanks to Rust's borrow checker, they - can't modify it. + (e.g., to store it in a database). However, consumers can't modify the + 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.