# type-equals [![crates.io](https://img.shields.io/crates/v/type-equals.svg)](https://crates.io/crates/type-equals) [![crates.io](https://img.shields.io/crates/d/type-equals.svg)](https://crates.io/crates/type-equals) [![docs.rs](https://docs.rs/type-equals/badge.svg)](https://docs.rs/type-equals) [![GitHub](https://img.shields.io/github/stars/SOF3/type-equals?style=social)](https://github.com/SOF3/type-equals) A trait for checking type equality. This crate implements the TypeEquals trick described in [rust-lang/rust#20041][comment]. The following compiles: ```rust use type_equals::TypeEquals; pub trait Owner { type Child1: Child; type Child2: Child; } pub trait Child { type Owner: Owner; } pub struct A; impl Owner for A { type Child1 = B; type Child2 = C; } pub struct B; impl Child for B { type Owner = A; } pub struct C; impl Child for C { type Owner = A; } pub fn want_child_one() where ::Child1: TypeEquals, {} pub fn want_child_two() where ::Child2: TypeEquals, {} pub fn this_works() { want_child_one::(); want_child_two::(); } ``` Meanwhile, the following does not compile: ```rust // A, B, C, want_child_one and want_child_two are declared identically. pub fn this_does_not_work() { want_child_one::(); want_child_two::(); } ``` [comment]: https://github.com/rust-lang/rust/issues/20041#issuecomment-564369542.