baggie
Baggie
is simple interface for storing any type of element in a HashMap
.
The crate has no dependencies, and is really just a helper around storing and
fetching Any
s from a HashMap
. It has no unsafe code and free of any unwraps
or similar misgivings.
The Baggie
implements a subset of methods found in HashMap.
The downside of this crate is you must know the type of what you stored later on. Typically this shouldn't be a problem, as you could keep some metadata structure describing what types belong to what keys you've stored.
Sometimes you might need a tool like this, but most times you should be using an enum. :)
use Baggie;
let mut bag = new;
// Insert any value type you wish...
bag.insert;
bag.insert;
bag.insert;
// Get a reference
let val3 = bag.;
assert_eq!;
// Get a mutable reference
let val2: = bag.get_mut;
match val2
let val2: &mut = bag.get_mut.unwrap;
assert_eq!;