In this chapter, we explored the basic and deeper concepts of generic and parameterized programming. We learned how to add lifetime, type, and trait parameters to declarations of types, traits, functions, and implementations. We also examined advanced techniques to selectively preserve or obscure type information as desired.
Applying these concepts to the elevator simulation, we observed how parameterization and generics can create fully abstract interfaces. By using trait objects, it is possible to completely separate trait interfaces from any implementation. We also observed the downsides or difficulties of parameterization and generics. Excessive use of parameterization can lead to parameter leaks, potentially requiring all code that interfaces with an interface to also become parameterized itself. On the other hand, we observed the difficulty associated with erasing...