fn encipher(&self, ptext: &str) -> CipherResult {
        input::is_alpha(ptext)?;

        let ptext = ptext.to_ascii_uppercase();
        let key = self.key.as_bytes();

        let ctext = ptext.bytes().map(move |c| key[(c - 65) as usize]).collect();

        Ok(String::from_utf8(ctext).unwrap())
    }
/// Enciphers the given plaintext (a str reference) using the Simple
/// Substitution cipher and returns the ciphertext as a `CipherResult`.
///
/// # Example
/// ```
/// use ciphers::{Cipher, Substitution};
///
/// let substitution = Substitution::new("PHQGIUMEAYLNOFDXJKRCVSTZWB");
///
/// let ctext = substitution.encipher("DEFENDTHEEASTWALLOFTHECASTLE");
/// assert_eq!(ctext.unwrap(), "GIUIFGCEIIPRCTPNNDUCEIQPRCNI");
/// ```
Enciphers the given plaintext (a str reference) using the Simple
Substitution cipher and returns the ciphertext as a `CipherResult`.
Enciphers the given plaintext ( a str reference ) using the Simple Substitution cipher and returns the ciphertext as a ` CipherResult ` .
fn encipher(&self, ptext: &str) -> CipherResult {
        input::is_alpha(ptext)?;
        let ptext = ptext.to_ascii_uppercase();
        let key = self.key.as_bytes();
        let ctext = ptext.bytes().map(move |c| key[(c - 65) as usize]).collect();
        Ok(String::from_utf8(ctext).unwrap())
    }
fn encipher ( & self , ptext : & str ) -> CipherResult { input :: is_alpha ( ptext ) ? ; let ptext = ptext . to_ascii_uppercase ( ) ; let key = self . key . as_bytes ( ) ; let ctext = ptext . bytes ( ) . map ( move | c | key [ ( c - 65 ) as usize ] ) . collect ( ) ; Ok ( String :: from_utf8 ( ctext ) . unwrap ( ) ) }
Enciphers the given plaintext (a str reference) using the Simple
Substitution cipher and returns the ciphertext as a `CipherResult`.
Enciphers the given plaintext ( a str reference ) using the Simple Substitution cipher and returns the ciphertext as a ` CipherResult ` .
&self
ptext
&str
&self
ptext
&str
example
```
use ciphers::{Cipher, Substitution}.

let substitution = Substitution::new("PHQGIUMEAYLNOFDXJKRCVSTZWB").

let ctext = substitution.encipher("DEFENDTHEEASTWALLOFTHECASTLE");
assert_eq!(ctext.unwrap(), "GIUIFGCEIIPRCTPNNDUCEIQPRCNI");
```
` ` ` use ciphers :: { Cipher Substitution } . let substitution = Substitution :: new ( " PHQGIUMEAYLNOFDXJKRCVSTZWB " ) . let ctext = substitution . encipher ( " DEFENDTHEEASTWALLOFTHECASTLE " ) ; assert_eq! ( ctext . unwrap () " GIUIFGCEIIPRCTPNNDUCEIQPRCNI " ) ; ` ` `