Check Letter with is_alphabetic()
Write a Rust function that takes a single character and returns true if it is an alphabetic letter using the char::is_alphabetic() method. This method checks if the character belongs to the Unicode Alphabetic category, which includes both uppercase and lowercase letters.
The char type in Rust represents a single Unicode scalar value (32-bit). Unlike C's char which is a byte, Rust's char can represent any Unicode character. The is_alphabetic() method is one of many category-checking methods on char, including is_numeric(), is_whitespace(), is_alphanumeric(), and more.
Rust's char methods are Unicode-aware by default. Unlike simple ASCII range checks (c >= 'a' && c <= 'z'), is_alphabetic() correctly handles accented characters and non-Latin alphabets. This makes Rust code more portable and correct for international applications.
Time complexity is O(1) as is_alphabetic() uses a character category lookup table. Space complexity is O(1). The method compiles to a constant-time lookup based on the character's Unicode category.
Edge cases include uppercase letters (return true), lowercase letters (return true), digits (return false), whitespace (return false), punctuation (return false), and Unicode letters from non-Latin scripts (also return true).
Example Input & Output
'a' is a letter
Space is not a letter
'm' is a letter
'5' is a digit, not a letter
'Z' is a letter
Algorithm Flow

Solution Approach
Best Answers
fn solution(c: char) -> bool {
c.is_alphabetic()
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
