Generic Types

Sometimes, the details of a data type just don't matter. Our code would work just as well no matter what the data type is, as long as it's something.

We've seen examples of this sort of situation many times already, such as with Result, Option, Rc, and so on. All of them, and many more, can work with a wide range of different data types, because they have one or more generic type parameters.

In this chapter, we're going to do the following:

  • Learn what generic type parameters are
  • Learn how to apply generic type parameters to data types
  • Learn how to apply generic type parameters to functions
  • Learn how generic types and trait objects differ
  • Create a complete and useful binary tree data structure
..................Content has been hidden....................

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