fn decrypt(&self, key: u32) -> String {
            // NOTE: % is the reminder operator in Rust, no modulus operator in the stdlib.
            let mod26 = |x| (x % 26) as u8;
            let char_to_enc = |ch| ch as u32 - 'a' as u32;
            let dec_to_char = |dec| char::from('a' as u8 + dec);
            let shift = mod26(key) as u32; // as u32 because we'll use it as mod26() input
            self.0.chars().map(|ch| {
                if is_dash(ch) {
                    ' '
                } else if is_ascii_lower(ch) {
                    let enc = char_to_enc(ch);
                    let dec = mod26(enc + shift);
                    dec_to_char(dec)
                } else { // unexpected
                    '?'
                }
            }).collect()
        }
/// Decrypt self using the given key.
///
/// Returns a decrypted representation of self.
// NOTE: Only dash and lower letters will be decrypted, other characters will be replaced
// by `?` (i.e. 0x3f). The puzzle `Room` encrypted names only contains dash and lower
// letters but this invariant is enforced at the `Room` level.
Decrypt self using the given key.
Returns a decrypted representation of self.
NOTE: Only dash and lower letters will be decrypted, other characters will be replaced
by `?` . The puzzle `Room` encrypted names only contains dash and lower
letters but this invariant is enforced at the `Room` level.
Decrypt self using the given key . Returns a decrypted representation of self . NOTE : Only dash and lower letters will be decrypted other characters will be replaced by ` ? ` . The puzzle ` Room ` encrypted names only contains dash and lower letters but this invariant is enforced at the ` Room ` level .
fn decrypt(&self, key: u32) -> String {
            // NOTE: % is the reminder operator in Rust, no modulus operator in the stdlib.
            let mod26 = |x| (x % 26) as u8;
            let char_to_enc = |ch| ch as u32 - 'a' as u32;
            let dec_to_char = |dec| char::from('a' as u8 + dec);
            let shift = mod26(key) as u32; // as u32 because we'll use it as mod26() input
            self.0.chars().map(|ch| {
                if is_dash(ch) {
                    ' '
                } else if is_ascii_lower(ch) {
                    let enc = char_to_enc(ch);
                    let dec = mod26(enc + shift);
                    dec_to_char(dec)
                } else { // unexpected
                    '?'
                }
            }).collect()
        }
fn decrypt ( & self , key : u32 ) -> String { // NOTE: % is the reminder operator in Rust, no modulus operator in the stdlib. let mod26 = | x | ( x % 26 ) as u8 ; let char_to_enc = | ch | ch as u32 - 'a' as u32 ; let dec_to_char = | dec | char :: from ( 'a' as u8 + dec ) ; let shift = mod26 ( key ) as u32 ; // as u32 because we'll use it as mod26() input self . 0 . chars ( ) . map ( | ch | { if is_dash ( ch ) { ' ' } else if is_ascii_lower ( ch ) { let enc = char_to_enc ( ch ) ; let dec = mod26 ( enc + shift ) ; dec_to_char ( dec ) } else { // unexpected '?' } } ) . collect ( ) }
Decrypt self using the given key.
Decrypt self using the given key .
&self
key
u32
&self
key
u32