March 2018
Intermediate to advanced
272 pages
7h 4m
English
There are a couple of traits we probably want many of our types to implement. The first of them is the Debug trait. The Debug trait should probably be implemented by all of our types, since it enables a developer to print debug information about our structures, enumerations, and so on. Moreover, it allows a user of our API to derive the Debug trait in structures using our API types by only adding an attribute.
We can enforce the implementation of this trait for all of our types by adding #![warn(missing_debug_implementations)]. The only detail is that this trait will only check for types exposed in our API. So, it will only work for pub types.
Another interesting trait is the Copy trait. Sometimes, we create ...
Read now
Unlock full access