Skip to content

Commit bbd0631

Browse files
Avoid incorrect attribution to the borrow-checker
1 parent 41ad768 commit bbd0631

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/idiomatic/leveraging-the-type-system/newtype-pattern/parse-don-t-validate.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ impl Username {
4444
ensuring that all instances of `Username` satisfy those checks.
4545

4646
- The `as_str` method allows consumers to access the raw string representation
47-
(e.g., to store it in a database) but, thanks to Rust's borrow checker, they
48-
can't modify it.
47+
(e.g., to store it in a database). However, consumers can't modify the
48+
underlying value since `&str`, the returned type, restricts them to read-only
49+
access.
4950

5051
- Stress the importance of evaluating _the entire API surface_ exposed by a
5152
newtype to determine if invariants are indeed bullet-proof.

0 commit comments

Comments
 (0)