Packages / rupm

rs-collections-interner 0.1.0

String interner that hands out small copyable ids, with resolve and statistics

Install

cargo add rs-collections-interner --registry rupm

In Ruststudio: Packages, search for rs-collections-interner, Install.

Owner: Rust Studio. Licence: MIT OR Apache-2.0. Total downloads: 0. Published 2026-11-23.

Versions

README

# rs-collections-interner

A string interner that stores each distinct string once and returns small copyable `Symbol` ids that compare in constant time. It can resolve ids back to strings and reports usage statistics.

## Install

Add it with `rupm add rs-collections-interner` (or `cargo add rs-collections-interner --registry rupm`).

## Usage

```rust
use rs_collections_interner::Interner;

let mut i = Interner::new();
let a = i.intern("hello");
assert_eq!(a, i.intern("hello"));
assert_eq!(i.resolve(a), Some("hello"));
println!("{:?}", i.stats());
```

## API overview

- `Interner::new`, `intern`, `try_intern`, `get`, `resolve`, `iter`, `len`, `is_empty`, `stats`
- `Symbol` (`Copy`, `Hash`, `Ord`, `index()`)
- `Stats { unique, lookups, hits, bytes }`