We can check if a character is in lowercase in Rust by using the is_lowercase()
method. This method returns a Boolean value. If the character is lowercase, then a true
is returned, otherwise false
.
character.is_lowercase()
There is only one parameter:
character
: This is the character we want to check if it is in lowercase.
A Boolean value true
or false
is returned.
fn main(){// create some characterslet char1 = 'E';let char2 = 'c';let char3 = 'X';let char4 = 'r';let char5 = '6';// check if characters are lowercaseprintln!("{}", char1.is_lowercase());println!("{}", char2.is_lowercase());println!("{}", char3.is_lowercase());println!("{}", char4.is_lowercase());println!("{}", char5.is_lowercase());}
is_lowercase()
method to see if some of the characters created were lowercase, then we print the results.