Text Processing
Slugify Label
Normalize Display Text
Small text pipelines can trim, lowercase, and replace characters to produce stable identifiers.
Program
Play the program to choose a label and turn it into a simple slug.
slugify_label.rs
fn main() {
let label = ;
let slug = label.trim().to_lowercase().replace(' ', "-");
println!("{slug}");
}
fn main() {
let label = ;
let slug = label.trim().to_lowercase().replace(' ', "-");
println!("{slug}");
}
fn main() {
let label = ;
let slug = label.trim().to_lowercase().replace(' ', "-");
println!("{slug}");
}
trim
`trim` removes leading and trailing whitespace before normalization.
lowercase
`to_lowercase` returns an owned `String` with lowercase text.
replace
`replace(' ', "-")` swaps spaces for hyphens in the normalized string.