Skip to content

Commit 60a6f9e

Browse files
Fix code examples
1 parent a025490 commit 60a6f9e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/idiomatic/leveraging-the-type-system/newtype-pattern/semantic-confusion.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ login(password, username);
2323

2424
The newtype pattern can prevent this class of errors at compile time:
2525

26-
```rust
26+
```rust,compile_fail
2727
pub struct Username(String);
2828
pub struct Password(String);
2929
# struct LoginError;
@@ -52,9 +52,9 @@ login(password, username); // 🛠️❌
5252
is of paramount importance, consider using a struct with named fields as
5353
input:
5454
```rust
55-
pub struct LoginArguments {
56-
pub username: &str,
57-
pub password: &str,
55+
pub struct LoginArguments<'a> {
56+
pub username: &'a str,
57+
pub password: &'a str,
5858
}
5959
# fn login(i: LoginArguments) {}
6060
# let password = "password";

0 commit comments

Comments
 (0)