| Crates.io | symspellrs |
| lib.rs | symspellrs |
| version | 0.1.4 |
| created_at | 2025-10-26 10:18:11.134892+00 |
| updated_at | 2025-10-26 10:24:46.065272+00 |
| description | Rust compile time library for symspell |
| homepage | |
| repository | https://github.com/Saphereye/symspellrs |
| max_upload_size | |
| id | 1901176 |
| size | 55,681 |
A compact Rust library implementing a SymSpell-style fuzzy-word suggestion algorithm. It supports two primary modes:
include_dictionary! proc-macro to embed a dictionary
(and optionally a precomputed deletion index) into the binary.SymSpell instance at runtime from an iterator of
(String, usize) pairs (word, frequency).This README contains quick usage commands, example snippets and developer commands.
Run the included example (demonstrates compile-time and runtime usage):
cargo run --example simple_usage
Run the test suite:
cargo test --workspace
Format and lint:
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
Build release artifacts:
cargo build --workspace --release
These small snippets show the most common usage patterns. See examples/simple_usage.rs
for a complete runnable example.
The include_dictionary! proc-macro reads a dictionary file at compile time (path is evaluated
relative to the crate root) and returns a ready-to-use value (when precompute = true you get
an EmbeddedSymSpell-like value backed by phf statics; otherwise the macro constructs a
runtime SymSpell).
use symspellrs::include_dictionary;
use symspellrs::Verbosity;
// Read tests/data/words.txt at compile time and build a ready value.
let sym = include_dictionary!("tests/data/words.txt", max_distance = 2, lowercase = true);
// Query the embedded instance:
let maybe_best = sym.find_top("helo"); // Option<Suggestion>
let closest = sym.lookup("helo", 2, Verbosity::Closest);
If you load dictionaries from the network, a database, or need to modify them at runtime,
use SymSpell::from_iter or SymSpell::load_iter:
use symspellrs::{SymSpell, Verbosity};
let entries = vec![
("hello".to_string(), 3usize),
("world".to_string(), 5usize),
];
let sym = SymSpell::from_iter(2, entries);
let results = sym.lookup("helo", 2, Verbosity::Top);
examples/simple_usage.rs — shows both compile-time embedding and runtime builder.tests/ — includes tests that exercise the compile-time macro and runtime lookup.