How it works...
Trait bounds specify the requirements of the implementation to implementers. In this way, we can call functions on generic types without having a more in-depth knowledge of their structures.
In Step 2, we require any parameter type to implement the std::fmt::Debug trait in order to be able to use the debug formatter for printing. However, that does not generalize well, and we have to require that implementation for any other function as well. That's why, in Step 4, we require that any type that implements the Loggable trait also implements Debug.
As a result, we can expect to use all the required traits in the trait's functions, which makes expansion easier and provides the ability for all types to implement the trait to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access