| Crates.io | refcount-interner |
| lib.rs | refcount-interner |
| version | 0.2.4 |
| created_at | 2020-07-13 15:22:02.472247+00 |
| updated_at | 2020-09-07 18:49:56.672041+00 |
| description | A simple reference-counted interning library for strings, slices, and other data |
| homepage | |
| repository | https://github.com/Ferdi265/refcount-interner |
| max_upload_size | |
| id | 264723 |
| size | 35,374 |
refcount-internerA simple reference-counted interning library for strings, slices, and other data.
This crate provides two kinds of owned interners that store the interned
data in the reference-counted types Rc<T> or Arc<T>. When the
shrink_to_fit() method is called on the interner, or when the interner is
dropped, unused interned objects are deallocated.
The two kinds of interners provided by this crate are RcInterner and
ArcInterner, returning Rc<T> and Arc<T> objects respectively.
use std::rc::Rc;
use refcount_interner::RcInterner;
let mut interner = RcInterner::new();
let hello = interner.intern_str("hello");
let world = interner.intern_str("world");
assert!(Rc::ptr_eq(&hello, &interner.intern_str("hello")));
Documentation is provided via rustdoc, and can be built with cargo doc, or
viewed online at
docs.rs/refcount-interner/.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.