Library reference

Convert text to uppercase

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

to_ascii_uppercase

Simple example

Change the case of two letters.

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

Everyday examples

Make the bus label match the route board.

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

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

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

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

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