In Rust, the to_lowercase()
method is used to convert a character or string to lowercase. It converts any letter that is not in lowercase to lowercase.
string.to_lowercase()
string
: This is a string or a character that we want to convert in lowercase.
It returns the object, string
, in lowercase.
fn main(){ // create some strings let gender = "M"; let name = "OKwuDiLi"; let role = "DEVELOPer"; // print string in lowercase println!("{} in lowercase = {}", gender, gender.to_lowercase()); println!("{} in lowercase = {}", name, name.to_lowercase()); println!("{} in lowercase = {}", role, role.to_lowercase()); }
to_lowercase()
method.RELATED TAGS
CONTRIBUTOR
View all Courses