Often times, you’ll write various versions of the same API. Is there a convenient way to check or enforce that your code is adhering to some API? Meaning the types of various named items are what you expect? In C you have header files that you can use for this purpose. Some example usages:
- Checking that the stable API you promised to your users hasn’t changed
- Keeping various versions of a
mod imp depending on some #[cfg()] consistent (this is also a common pattern in std)
NB using traits is not sufficient, because not every item can be expressed as a trait member.