13 releases (breaking)
Uses new Rust 2024
| new 0.44.0 | Mar 1, 2026 |
|---|---|
| 0.42.0 | Jan 6, 2026 |
| 0.41.0 | Dec 31, 2025 |
#631 in Text processing
1,778 downloads per month
Used in 10 crates
(2 directly)
43KB
925 lines
facet-singularize
Fast, no-regex English singularization.
Overview
This crate converts plural English words to their singular form without using regex.
It's designed for use in deserialization where performance matters—for example, when
mapping JSON field names like "dependencies" to Rust struct fields like dependency.
Example
use facet_singularize::singularize;
assert_eq!(singularize("dependencies"), "dependency");
assert_eq!(singularize("items"), "item");
assert_eq!(singularize("children"), "child");
assert_eq!(singularize("boxes"), "box");
assert_eq!(singularize("matrices"), "matrix");
Features
- No regex: Uses simple suffix matching and table lookups
- no_std compatible: Works without the standard library (with
allocfeature) - Irregular plurals: Handles common exceptions like children→child, mice→mouse
- Latin/Greek plurals: Supports -ices→-ix (matrices→matrix), -ae→-a (larvae→larva)
Performance
Benchmarked to be fast enough for hot paths. The implementation prioritizes predictable performance over completeness—it handles the common cases well rather than trying to be a full linguistic library.
Part of the Facet Ecosystem
This crate is part of the facet ecosystem, providing reflection for Rust.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Dependencies
~0–16MB
~165K SLoC