serde-hashkey
Serde-based in-memory key serialization which supports hashing.
This allows any serde-serializable type to be converted into a value which
implements PartialEq, Eq, ParialOrd, Ord, and Hash.
Key is useful because it allows for a form of type-erasure. Let's say you want to build a generic in-memory key-value store where you want to store arbitrary serde-serializable keys. This is typical for things like caches or dependency injection frameworks.
Float policies
By default, Key can't include floating point types such as f32 and
f64. Neither of these are totally ordered nor hashable.
To enable the Key type to use f32 and f64 it can be constructed with a
specific float policy.
Available float policies are:
- RejectFloat - the default behavior when using to_key.
- OrderedFloat - the behavior when using to_key_with_ordered_float. The
ordered-floatfeature must be enabled to use this. The behavior is derived from theordered-floatcrate.
Features
ordered-float- Enables serializing floating point numbers through behavior derived from theordered-floatcrate
Examples
You can run this example with
cargo run --example book
use ;
use ;
use ;
License: MIT/Apache-2.0