varmap 0.1.1

Fast, heterogeneous key-value maps for Rust. Store mixed types (integers, strings, bytes, custom structs) under a single key namespace, with compile-time keys, runtime strings, or enum variants. Arena-backed for zero-copy reads of strings and byte slices.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::*;

impl VarMapValue for char {
    type Decoded<'a> = char;

    const TYPE_ID: u32 = 0;

    fn to_value<'a>(&self, builder: &'a mut ValueBuilder<'a>) -> Value<'a> {
        Value::new(ValueKind::Char(*self), builder.arena())
    }

    fn from_value<'a>(value: &Value<'a>) -> Option<char> {
        match value.kind() {
            ValueKind::Char(c) => Some(*c),
            _ => None,
        }
    }
}