1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-07-11 16:50:16 +02:00

Avoid incorrect attribution to the borrow-checker

This commit is contained in:
LukeMathWalker
2025-07-07 16:05:34 +02:00
parent 41ad768fd6
commit bbd0631fe4

View File

@ -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.