refcount-interner

Crates.iorefcount-interner
lib.rsrefcount-interner
version0.2.4
sourcesrc
created_at2020-07-13 15:22:02.472247
updated_at2020-09-07 18:49:56.672041
descriptionA simple reference-counted interning library for strings, slices, and other data
homepage
repositoryhttps://github.com/Ferdi265/refcount-interner
max_upload_size
id264723
size35,374
Ferdinand Bachmann (Ferdi265)

documentation

README

refcount-interner

A 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.

Example

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

Documentation is provided via rustdoc, and can be built with cargo doc, or viewed online at docs.rs/refcount-interner/.

License

Licensed under either of

at your option.

Contribution

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.

Commit count: 16

cargo fmt