rust - Check whether a char is an alphabet or number? -


what rust equivalents c's isalpha, isdigit , isalnum?

is_alphabetic, is_digit, is_alphanumeric, is_numeric looking for.

e.g. :

fn main() {     println!("1 digit {}", '1'.is_digit(10));     println!("f hex digit {}", 'f'.is_digit(16));     println!("a alphabetic {}", 'a'.is_alphabetic());     println!("こis alphabetic {}", 'こ'.is_alphabetic());     println!("a alphanumeric {}", 'a'.is_alphanumeric());     println!("1 alphanumeric {}", '1'.is_alphanumeric()); } 

returns:

1 digit true f hex digit true alphabetic true こis alphabetic true alphanumeric true 1 alphanumeric true 

they described in detail in rust standard library docs chars.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -