1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-07-12 09:10:40 +02:00

Fix code examples

This commit is contained in:
LukeMathWalker
2025-07-08 10:31:22 +02:00
parent a025490afd
commit 60a6f9e836

View File

@ -23,7 +23,7 @@ login(password, username);
The newtype pattern can prevent this class of errors at compile time: The newtype pattern can prevent this class of errors at compile time:
```rust ```rust,compile_fail
pub struct Username(String); pub struct Username(String);
pub struct Password(String); pub struct Password(String);
# struct LoginError; # struct LoginError;
@ -52,9 +52,9 @@ login(password, username); // 🛠️❌
is of paramount importance, consider using a struct with named fields as is of paramount importance, consider using a struct with named fields as
input: input:
```rust ```rust
pub struct LoginArguments { pub struct LoginArguments<'a> {
pub username: &str, pub username: &'a str,
pub password: &str, pub password: &'a str,
} }
# fn login(i: LoginArguments) {} # fn login(i: LoginArguments) {}
# let password = "password"; # let password = "password";