You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-07-12 17:20:14 +02:00
Use a more coincise symbol to signal compilation errors in slides
This commit is contained in:
@ -19,8 +19,7 @@ fn double(n: u64) -> u64 {
|
|||||||
n * 2
|
n * 2
|
||||||
}
|
}
|
||||||
|
|
||||||
// This doesn't compile ❌
|
double(UserId(1)); // 🛠️❌
|
||||||
double(UserId(1));
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The Rust compiler won't implicitly convert to (or from) the underlying type.\
|
The Rust compiler won't implicitly convert to (or from) the underlying type.\
|
||||||
@ -28,8 +27,7 @@ It won't let you use methods or operators defined on the underlying type either:
|
|||||||
|
|
||||||
```rust,compile_fail
|
```rust,compile_fail
|
||||||
# pub struct UserId(u64);
|
# pub struct UserId(u64);
|
||||||
// This doesn't compile ❌
|
assert_ne!(UserId(1), UserId(2)); // 🛠️❌
|
||||||
assert_ne!(UserId(1), UserId(2));
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
@ -35,8 +35,7 @@ pub fn login(username: &Username, password: &Password) -> Result<(), LoginError>
|
|||||||
|
|
||||||
# let password = Password("password".into());
|
# let password = Password("password".into());
|
||||||
# let username = Username("username".into());
|
# let username = Username("username".into());
|
||||||
// Compiler error 🎉
|
login(password, username); // 🛠️❌
|
||||||
login(password, username);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
Reference in New Issue
Block a user