Using Traits From std
Inside the std
crate, there’s a module called ops
. Most of the operators we use, like +
or *
, are backed up by traits in that module. This allows us to use these operators on lots of different types. It also means that, if we feel like it, we can bypass the operators and use trait methods directly instead. However, we’re going to run into a new restriction, which is exactly why we’re discussing this topic now.
Let’s try to add two numbers together using the add
method: