Rust

StringZilla for Rust

cargo add stringzilla 6.0.0-rc.1 · 91a27bdd

It exposes its functions, traits, and engines directly at the crate root, covering two kinds of work:

  • single-string operations — search, counting, splitting, hashing, sorting, UTF-8 segmentation, normalization, and case folding.
  • batch engines — Levenshtein distances, window overlap, and multi-pattern substring search, each a stateful cross-product engine prepared once from a batch of queries and reused across every later round.

The crate is no_std-friendly and SIMD-accelerated; most of the single-string surface is exposed both as free functions and as ergonomic extension-trait methods on any AsRef<[u8]> — &str, String, &[u8], Vec<u8>, Cow<str>, and more. The engines take slices of anything AsRef<[u8]> and write into caller-owned buffers at a caller-chosen stride, so a pipeline allocates once and reuses those buffers across every batch.

Topics

Installation1
Types36The sz module exposes a handful of public value types used throughout the API.
Searching and Counting75All search functions accept any AsRef<[u8]> and return byte offsets as Option<usize>.
Comparison and Equality2order and equal are SIMD byte comparisons, while utf8uncasedorder compares under Unicode case folding.
Splitting and Partitioning18The crate exposes iterator-based match and split operations.
Trimming and Translating4The crate provides byte-level buffer transforms, lookup-table translation, in-place replacement, and Unicode case folding / normalization.
Unicode Segmentation50A single emoji such as the flag 🇺🇸 is 8 bytes and 2 codepoints, yet a reader sees one character — one grapheme cluster.
Case Folding and Normalization17utf8uncasedfold case-folds into a target buffer, utf8norm applies a Unicode normal form, and utf8finddenormalized checks conformance without rewriting.
Hashing and Checksums46These free functions cover a byte checksum, seeded and unseeded 64-bit hashes, and a multi-seed hash that fills an output slice in one pass.
Sorting and Sets10argsort writes the sorted permutation of a slice into a caller-provided order slice, while argsortby sorts by a byte-slice key extracted from each element.
Memory Operations3
Edit Distances6LevenshteinEngine prepares a batch of queries once — Myers' bit-parallel masks, the capability, and on a device the launch geometry — then scores as many batches of candidates against it as a caller has.
Fingerprints5OverlapEngine hashes and sorts a batch of queries into one B-tree forest over every window width, then streams candidates through it.
Runtime Dispatch34The producers report Capabilities, a set of Capability bits, for the CPU or for one GPU by its runtime's own ordinal.