dyncollections
This library provides a bunch of collections to store trait objects and retrive concrete types from them.
Example usage
The simplest collection is DynSet which is similar to Vec<T> but allows you to store different types which implement the same trait and get them back as concrete types.
Example:
use DynSet;
// Creating our trait and a few types that implement it
;
;
// We must use the `dynamify!()` macro to make our trait usable with `DynSet`
dynamify!;
let mut set = new;
// Every push call returns a key that can be used to get the value back with correct type.
let hello_key = set.push;
let world_key = set.push;
assert_eq!;
assert_eq!;
// We can also iterate over `DynSet`. Iterator will yield trait objects
let messages = dynset.iter.map.;
assert_eq!;
Other collections
Except for DynSet, dyncollections also provides OrdDynMap and HashDynMap which act similarly to their standard library counterparts except that they use similar mechanism to retrieve back type data from trait objects.
Features
impl_std(enabled by default) - implements innerMakeConcrete<T>trait for a bunch of standard library types