2 unstable releases

Uses old Rust 2015

0.2.0 Apr 7, 2018
0.1.0 Apr 7, 2018

#78 in Caching

Download history 5/week @ 2020-11-26 3/week @ 2020-12-03 3/week @ 2020-12-10 4/week @ 2021-01-14 8/week @ 2021-02-11

915 downloads per month

Apache-2.0 OR MIT

14KB
201 lines

simple-interner

A very simplistic interner based around giving out (wrapped) references rather than some placeholder symbol. This means that e.g. strings can be interned in systems based around &str without rewriting to support a new Symbol type.

The typical use case for something like this is text processing chunks, where chunks are very likely to be repeated. For example, when parsing source code, identifiers are likely to come up multiple times. Rather than have a Token::Identifier(String) and allocate every occurrence of those identifiers separately, interners allow you to store Token::Identifier(Symbol), and compare identifier equality by the interned symbol.

This crate exists to give the option of using a simplistic interface. If you want or need further power, there are multiple other options available on crates.io.


lib.rs:

A very simplistic interner based around giving out (wrapped) references rather than some placeholder symbol. This means that e.g. strings can be interned in systems based around &str without rewriting to support a new Symbol type.

The typical use case for something like this is text processing chunks, where chunks are very likely to be repeated. For example, when parsing source code, identifiers are likely to come up multiple times. Rather than have a Token::Identifier(String) and allocate every occurrence of those identifiers separately, interners allow you to store Token::Identifier(Symbol), and compare identifier equality by the interned symbol.

This crate exists to give the option of using a simplistic interface. If you want or need further power, there are multiple other options available on crates.io.

Dependencies

~0–355KB