Decrypt String from Alphabet to Integer Mapping LeetCode solution in Rust
1impl Solution {2pub fn freq_alphabets(s: String) -> String {3let mut iter = s.chars().rev().peekable();4let mut res = String::new();5loop {6match iter.next() {7Some('#') => {8let c1 = iter.next().unwrap().to_digit(10).unwrap() as u8;9let c2 = iter.next().unwrap().to_digit(10).unwrap() as u8;10res.push((c2 * 10 + c1 - 1 + 'a' as u8) as char)11}12Some(x) => {13let c = x.to_digit(10).unwrap() as u8;14res.push((c - 1 + 'a' as u8) as char);15}16_ => {}17}18if iter.peek() == None {19break;20}21}22res.chars().rev().collect()23}24}