bumpalo-intern 0.2.1

String intern utility combined with Bumpalo.
Documentation
use bumpalo_intern::dense::{Interned, Keyed};

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
struct MyInterned<'a>(&'a str);

impl<'a> Keyed<'a> for MyInterned<'a> {
    fn intern_key(&self) -> &'a str {
        self.0
    }
}

impl<'a> Interned<'a> for MyInterned<'a> {
    type View<'b> = MyInterned<'b>;

    fn intern_from<'b>(arena: &'a bumpalo::Bump, value: Self::View<'b>) -> (&'a str, Self) {
        let key = arena.alloc_str(value.0);
        (key, MyInterned(key))
    }
}