Library reference

Convert text to lowercase

Give these short labels the same letter case. All four inputs use plain English letters and digits.

to_ascii_lowercase

Simple example

Change the case of two letters.

Start'AB'
Resultab
main.rs
fn main() {
    println!("{}", "AB".to_ascii_lowercase());
}
Output
ab
Advertisements

Everyday examples

Make the bus label match the route board.

Start'BUS'
Resultbus
main.rs
fn main() {
    println!("{}", "BUS".to_ascii_lowercase());
}
Output
bus

Give an art shelf the same lettering as the other shelves.

Start'ART'
Resultart
main.rs
fn main() {
    println!("{}", "ART".to_ascii_lowercase());
}
Output
art

Normalize the letters in a ticket code and keep its digits.

Start'B12'
Resultb12
main.rs
fn main() {
    println!("{}", "B12".to_ascii_lowercase());
}
Output
b12
Run the example
Terminal
rustc main.rs
./main
Official documentation