We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a025490 commit 60a6f9eCopy full SHA for 60a6f9e
src/idiomatic/leveraging-the-type-system/newtype-pattern/semantic-confusion.md
@@ -23,7 +23,7 @@ login(password, username);
23
24
The newtype pattern can prevent this class of errors at compile time:
25
26
-```rust
+```rust,compile_fail
27
pub struct Username(String);
28
pub struct Password(String);
29
# struct LoginError;
@@ -52,9 +52,9 @@ login(password, username); // 🛠️❌
52
is of paramount importance, consider using a struct with named fields as
53
input:
54
```rust
55
- pub struct LoginArguments {
56
- pub username: &str,
57
- pub password: &str,
+ pub struct LoginArguments<'a> {
+ pub username: &'a str,
+ pub password: &'a str,
58
}
59
# fn login(i: LoginArguments) {}
60
# let password = "password";
0 commit comments