thisisplural
#[derive(Plural)] for creating frictionless new types with a Vec, HashMap, etc.
Features
- Automatically implements
From,Into,FromIterator,IntoIterator,Deref, andDerefMut. - Supports
VecandHashMap(adding other collections to here is very easy).
Example
// This implements `From`, `Into`, `FromIterator`, `IntoIterator`, `Deref`, and `DerefMut`.
;
// use `From` trait
let mut my_favorite_numbers: Numbers = vec!.into;
// use inner APIs with `DerefMut` trait.
my_favorite_numbers.push;
// `FromIterator` allows this `collect()`
let doubled_numbers: Numbers = my_favorite_numbers.iter.map.collect;
// `HashMap` is also supported
;
// construct the struct with using `FromIterator`
let favorite_numbers =
from_iter;
// use it in a `for` loop (`IntoIterator` trait)
for in favorite_numbers