Crate assert_type_eq [] [src]

Statically assert that types from potentially different crate versions via different dependencies are identical.

Until RFC 1977 (public dependencies) is accepted, the situation where multiple different versions of the same crate are present is possible. In most situations this will simply cause code to not compile, as types mismatch, however with runtime structures like TypeMap this leads to runtime errors (often silent!) instead. This macro allows compile-time assertion that types via different dependencies are identical, and will interoperate, which is easier to debug than runtime errors.


extern crate assert_type_eq;

pub mod my_crate {
    pub struct MyStruct;

mod a {
    pub use super::my_crate;

mod b {
    pub use super::my_crate;


fn main() {
    // ...

Specify all versions of the same type via different dependencies. Any types that do not match the first type in the macro will cause a compile-time error.