You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a slide on the various operator traits in the standard library, which focuses on their overall design and how to implement these for our own types so we can use operator syntax with them. This is good, but there are a couple semantic surprises in how Rust operators behave, which we should note explicitly.
One is that the Neg operator (!) does not "boolify" like the C/C++/JS incarnations of this operator; it instead negates each bit of an integer, so !5u8 is 250.
Another is that the &&/|| operators are not tied to traits because they are lazy in their right-hand sides, so they cannot be used with user-defined types.
The text was updated successfully, but these errors were encountered:
We have a slide on the various operator traits in the standard library, which focuses on their overall design and how to implement these for our own types so we can use operator syntax with them. This is good, but there are a couple semantic surprises in how Rust operators behave, which we should note explicitly.
One is that the
Neg
operator (!
) does not "boolify" like the C/C++/JS incarnations of this operator; it instead negates each bit of an integer, so!5u8
is 250.Another is that the
&&
/||
operators are not tied to traits because they are lazy in their right-hand sides, so they cannot be used with user-defined types.The text was updated successfully, but these errors were encountered: