Introducing Generics, Impl, and Traits

One of the key benefits of any modern language is the ability to be able to use a type which can be anything. Not only does this reduce the amount of code required, but it allows for greater flexibility in code creation. Rust not only allows for generic types and functions, but introduces traits; these can be considered as a logical extension of generics, as they tell the compiler the functionality the type must provide.

In this chapter, we will take a look at the following topics:

  • Generics in Rust
  • Impl and traits
  • Generic types
  • Trait objects
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset