pub fn decrypt<'a>(secret: &'a str, shift: &'a u8) -> Result<String, &'a str> {
    match validations(&secret, &shift) {
        None => (),
        Some(v) => return Err(v),
    };

    let mut result: String = String::new();

    for c in secret.chars() {
        if c.is_whitespace() {
            result.push(c.clone());
        } else if c.is_uppercase() {
             result.push(
                 shift_left_char(&c, UPPERCASE_CHARS, &shift)
             )
        } else {
            result.push(
                shift_left_char(&c, LOWERCASE_CHARS, &shift)
            )
        }
    }

    Ok(result)
}
/// Decrypts a text with given shift using Caesar
/// 
/// # Examples
/// 
/// ```
/// decrypt("abcd", &1u8)
/// ```
Decrypts a text with given shift using Caesar
Decrypts a text with given shift using Caesar
pub fn decrypt<'a>(secret: &'a str, shift: &'a u8) -> Result<String, &'a str> {
    match validations(&secret, &shift) {
        None => (),
        Some(v) => return Err(v),
    };
    let mut result: String = String::new();
    for c in secret.chars() {
        if c.is_whitespace() {
            result.push(c.clone());
        } else if c.is_uppercase() {
             result.push(
                 shift_left_char(&c, UPPERCASE_CHARS, &shift)
             )
        } else {
            result.push(
                shift_left_char(&c, LOWERCASE_CHARS, &shift)
            )
        }
    }
    Ok(result)
}
pub fn decrypt < ' a > ( secret : & ' a str , shift : & ' a u8 ) -> Result < String , & ' a str > { match validations ( & secret , & shift ) { None => ( ) , Some ( v ) => return Err ( v ) , } ; let mut result : String = String :: new ( ) ; for c in secret . chars ( ) { if c . is_whitespace ( ) { result . push ( c . clone ( ) ) ; } else if c . is_uppercase ( ) { result . push ( shift_left_char ( & c , UPPERCASE_CHARS , & shift ) ) } else { result . push ( shift_left_char ( & c , LOWERCASE_CHARS , & shift ) ) } } Ok ( result ) }
Decrypts a text with given shift using Caesar
Decrypts a text with given shift using Caesar
secret
&'a str
shift
&'a u8
secret
&'a str
shift
&'a u8
examples
None