6 个版本
| 0.2.4 | 2020年9月7日 |
|---|---|
| 0.2.3 | 2020年7月24日 |
| 0.1.0 | 2020年7月13日 |
#298 在 缓存
23KB
166 行
refcount-interner
一个简单的引用计数字符串、切片和其他数据的缓存库。
此crate提供两种类型的所有者缓存库,将缓存数据存储在引用计数字类 Rc<T> 或 Arc<T> 中。当在缓存库上调用 shrink_to_fit() 方法或缓存库被丢弃时,未使用的缓存对象将被释放。
此crate提供的两种类型的缓存库是 RcInterner 和 ArcInterner,分别返回 Rc<T> 和 Arc<T> 对象。
示例
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")));
文档
文档通过 rustdoc 提供,可以使用 cargo doc 构建,或在网上查看 docs.rs/refcount-interner/。
许可协议
许可协议为以下之一
- Apache License,版本 2.0 (LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT 许可协议 (LICENSE-MIT 或 https://open-source.org.cn/licenses/MIT)
任选其一。
贡献
除非您明确声明,否则根据 Apache-2.0 许可证定义的,您有意提交给作品的所有贡献,将按照上述双重许可,没有任何附加条款或条件。