limace
limace is a fast and minimal slugification utility for Rust. It converts strings into clean, URL-friendly slugs using ASCII characters only. It handles Unicode characters via transliteration and supports customizable separator characters.
Features
- Transliterates Unicode to ASCII using
deunicode - Strips punctuation and special characters
- Converts to lowercase
- Customizable separator (default is
-) - No heap allocations beyond the result
String
Example
use Slugifier;
Usage
Add this to your Cargo.toml:
[]
= "0.1"
Then use it in your code:
use Slugifier;
let slug = default.slugify;
assert_eq!;
Custom separator
You can change the separator using with_separator():
use Slugifier;
let slug = default
.with_separator
.slugify;
assert_eq!;
How it works
- Unicode characters are transliterated to ASCII using
deunicode_char(). - Uppercase letters are manually lowercased.
- Alphanumeric ASCII characters are kept.
- All other characters are replaced by a separator.
- Consecutive separators are collapsed into one.
License
Licensed under MIT