unicase
A case-insensitive string wrapper for Rust using Unicode case-folding.
Repository Health
Technical Analysis
unicase wraps Rust strings so they compare and hash as case-insensitive, using full Unicode case-folding rules by default (with an opt-in ASCII-only fast path). It’s a small, dependency-light building block widely used by HTTP and MIME libraries that need case-insensitive header/type matching.
What You Get
- UniCase<S> wrapper type for case-insensitive Eq/Hash/Ord over any string-like type
- A dedicated Ascii wrapper for a faster ASCII-only case-insensitive fast path
- Full Unicode case-folding tables for correct handling of non-ASCII scripts
- no_std compatibility for use in embedded or constrained environments
Common Use Cases
- Matching HTTP header names or MIME type strings case-insensitively (as used by hyper and mime)
- Using strings as case-insensitive HashMap/HashSet keys without allocating a lowercased copy
- Comparing user-supplied identifiers (usernames, file extensions) where case shouldn’t matter
- Sorting or deduplicating string collections where case variants should be treated as equal
Under The Hood
Architecture - lib.rs defines the generic UniCase<S> wrapper and its trait implementations; ascii.rs provides the narrower Ascii type for an ASCII-only fast path, while unicode/mod.rs and the large generated unicode/map.rs table implement full Unicode case-folding lookups used by UniCase’s default comparison path. Tech Stack - Pure Rust (edition 2018), zero required runtime dependencies, no_std-compatible, with an optional nightly feature flag for nightly-only optimizations; the Unicode folding tables in map.rs are generated from Unicode Consortium case-folding data via a Python script in scripts/. Code Quality - Unit tests live alongside implementation in lib.rs, ascii.rs, and the unicode module, covering both the ASCII fast path and Unicode case-folding edge cases (e.g. German ß vs SS); the crate has a very long track record (created 2014) as a dependency of hyper/mime with 329M+ total downloads, though commit activity is now infrequent. API Design - The API is deliberately minimal — a single generic wrapper type plus a narrower ASCII variant — designed to be a drop-in replacement wherever a String/&str is used as a map key or compared for equality, at the cost of documentation being sparse beyond doctests in the README.
Used by 3 apps in this directory
Arroyo
Data Engineering · Analytics
A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.
Enso
Analytics · Data Engineering · Low Code Platforms
A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.
Zed
Developer Tools · Collaboration · Code Editors
High-performance, multiplayer code editor built in Rust by the creators of Atom and Tree-sitter, with native AI integration and real-time collaboration.