eclectic 0.3.0

Experimental collection traits.
docs.rs failed to build eclectic-0.3.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: eclectic-0.11.0

Collection traits for generic programming.

Code that uses these traits should use them as generally as possible. For example, consider the following function that fills a map with default values for some keys:

use eclectic::map::*;

fn fill<M, K>(keys: K) -> M
where
    M: Default + Map,
    K: IntoIterator<Item = M::Key>,
    M::Value: Default,
{
    let mut map = M::default();
    for key in keys { map.insert(key, M::Value::default()); }
    map
}

Map is a convenient shorthand for code that uses multiple map APIs, but this code only ever calls insert, so it could be rewritten more generally as:

use eclectic::map;

fn fill<M, K>(keys: K) -> M
where
    M: Default + map::Insert,
    K: IntoIterator<Item = M::Key>,
    M::Value: Default,
{
    let mut map = M::default();
    for key in keys { map.insert(key, M::Value::default()); }
    map
}