We can covert a character to lowercase in Rust by passing the character to to_lowercase()
method.
character.to_lowercase()
character
: This is the character that we want to convert to lowercase.
The value returned is an lowercase equivalent of the character character
.
fn main(){ // create some characters let char1 = 'o'; let char2 = 'T'; let char3 = 'A'; let char4 = 'Z'; let char5 = 'x'; // Convert to lowercase println!("{}", char1.to_lowercase()); println!("{}", char2.to_lowercase()); println!("{}", char3.to_lowercase()); println!("{}", char4.to_lowercase()); println!("{}", char5.to_lowercase()); }
to_lowercase()
method and print the values to the console.RELATED TAGS
CONTRIBUTOR
View all Courses