fast-map
A small library and custom derive to create a map-like struct that uses match expressions to get
and insert
values.
If you know your keys at compile-time, this library will likely be faster than HashMap
for supported map operations.
Provides the following operations on the wrapping struct (via derive
macros):
MyMap::get
, returnsResult<Option<&V>, Error>
MyMap::get_mut
, returnsResult<Option<&mut V>, Error>
MyMap::insert
, returnsResult<Option<V>, Error>
, whereV
is the old value if one existsMyMap::remove
, returnsResult<Option<V>, Error>
MyMap::values
, returns an iterator over&V
s
If you know that your operations cannot fail (e.g. if your key type is an enum
, and you list all variants as keys),
you can add infallible = true
to your derive attributes, which will unwrap
the result of your map operations.
Usage
Changelog
0.2.1
- Add the non-erroring operations back as depending on macro attribute (
infallible = true
). Default isfalse
.
0.2.0
- Removed
easy
andstrict
MapLike
traits. It's better to handle unknown keys explicitly, even forget
s. - Added
get_mut
operation to the wrapping struct
Current version: 0.2.1
License: MIT