/// Parse a hexadecimal sha1 hash, or crash.
Parse a hexadecimal sha1 hash, or crash.
Parse a hexadecimal sha1 hash or crash .
fn parse_sha1(sha1_hex: &str) -> [u8; 20] {
    assert_eq!(sha1_hex.len(), 40);
    let mut sha1 = [0; 20];
    for i in 0..20 {
        let byte_str = &sha1_hex[i * 2..i * 2 + 2];
        let byte = u8::from_str_radix(byte_str, 16).expect("Expected hexadecimal SHA1 hash.");
        sha1[i] = byte;
    }
    sha1
}
fn parse_sha1 ( sha1_hex : & str ) -> [ u8 ; 20 ] { assert_eq ! ( sha1_hex len ( ) 40 ) ; let mut sha1 = [ 0 ; 20 ] ; for i in 0 .. 20 { let byte_str = & sha1_hex [ i * 2 .. i * 2 + 2 ] ; let byte = u8 :: from_str_radix ( byte_str , 16 ) . expect ( " " ) ; sha1 [ i ] = byte ; } sha1 }
Parse a hexadecimal sha1 hash, or crash.
Parse a hexadecimal sha1 hash or crash .
sha1_hex
&str