unicase

A case-insensitive string wrapper for Rust using Unicode case-folding.

Library
Cargo
v2.9.0
99stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
44/100Fair
Development Activity28
Maintenance24
Community52
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
64/100Good
Architecture62
Code Quality68
Innovation50
Learning Curve75

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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search