kaira/lib.rs
1pub fn is_key(input: &str) -> bool {
2 if input.as_bytes()[0usize] != b'-' {
3 return false;
4 }
5
6 if input.as_bytes()[1usize] != b'-' {
7 if input.len() != 2 {
8 return false;
9 }
10
11 return input.chars().nth(1).unwrap().is_alphabetic();
12 }
13
14 return input[2..].chars().all(|c| c.is_alphanumeric());
15}
16
17#[cfg(test)]
18mod tests {
19 use super::*;
20
21 #[test]
22 fn test_alphanumeric() {
23 let key = "--key";
24 assert_eq!(is_key(key), true);
25 }
26}