Search⌘ K

Using Traits From std

Explore how to use traits from Rust's standard library by bringing them into scope with use statements. Understand the importance of the prelude and how to fix errors when accessing trait methods like add on types such as i32.

We'll cover the following...

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 ...