[![Crates.io](https://img.shields.io/crates/v/type-sets)](https://crates.io/crates/type-sets) [![Documentation](https://docs.rs/type-sets/badge.svg)](https://docs.rs/type-sets) # Type-sets Sets implemented in the rust type-system. This crate allows the creation of type-sets within the rust type-system. These sets can be compared using `SubsetOf` and `SupersetOf`. All traits are marked unsafe, except for `AsSet`, giving guarantees about conflicting implementations for use in `unsafe` code. Sets are implemented up to 12 items. This library was created for use in [`meslin`](https://github.com/jvdwrf/Meslin), but is general enough that there could be other purposes as well. ## Example ```rust use type_sets::*; use std::any::TypeId; // We can define functions, that may only be called if the parameter `T` is // a subset or superset of another set. fn is_subset>() {} fn is_superset>() {} fn contains_u64>() {} // We can also use custom structs as sets struct MySet; impl AsSet for MySet { type Set = Set![u32]; } fn main() { is_subset::(); // compiles is_subset::(); // compiles is_subset::(); // is_subset::(); // does not compile is_superset::(); // compiles is_superset::(); // compiles is_superset::(); // compiles // is_superset::(); // does not compile is_subset::(); // compiles // is_superset::(); // does not compile contains_u64::(); // contains_u64::(); // does not compile assert_eq!( ::members(), [TypeId::of::(), TypeId::of::()] ); assert_eq!( MySet::members(), [TypeId::of::()] ); } ```