mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-01-08 00:57:56 +02:00
operators.md: mention Not trait's un-C-like behavior (#2279)
Fixes #2072.
This commit is contained in:
parent
fa6055c297
commit
f6a3c07ea3
@ -44,6 +44,11 @@ Discussion points:
|
||||
- You could implement `Add` for two different types, e.g.
|
||||
`impl Add<(i32, i32)> for Point` would add a tuple to a `Point`.
|
||||
|
||||
The `Not` trait (`!` operator) is notable because it does not "boolify" like the
|
||||
same operator in C-family languages; instead, for integer types it negates each
|
||||
bit of the number, which arithmetically is equivalent to subtracting it from -1:
|
||||
`!5 == -6`.
|
||||
|
||||
</details>
|
||||
|
||||
[1]: https://doc.rust-lang.org/std/ops/index.html
|
||||
|
Loading…
Reference in New Issue
Block a user