fn hash_to_vec(hash: &str) -> Vec<u8> {
    let mut converted: Vec<u8> = Vec::new();
    for char in hash.chars() {
        // assume only hex compatible chars
        let x = match char {
            '0' => 0x0u8,
            '1' => 0x1,
            '2' => 0x2,
            '3' => 0x3,
            '4' => 0x4,
            '5' => 0x5,
            '6' => 0x6,
            '7' => 0x7,
            '8' => 0x8,
            '9' => 0x9,
            'A' | 'a' => 0xA,
            'B' | 'b' => 0xB,
            'C' | 'c' => 0xC,
            'D' | 'd' => 0xD,
            'E' | 'e' => 0xE,
            'F' | 'f' => 0xF,
            _ => panic!("Unsupported character"),
        };
        converted.push(x);
    }

    let chunks = converted.chunks(2);
    let mut result: Vec<u8> = Vec::new();
    for chunk in chunks {
        result.push((chunk[0] << 4) + chunk[1]);
    }
    result
}
/// Convert an object hash to a vector for usable in the index file
Convert an object hash to a vector for usable in the index file
Convert an object hash to a vector for usable in the index file
fn hash_to_vec(hash: &str) -> Vec<u8> {
    let mut converted: Vec<u8> = Vec::new();
    for char in hash.chars() {
        // assume only hex compatible chars
        let x = match char {
            '0' => 0x0u8,
            '1' => 0x1,
            '2' => 0x2,
            '3' => 0x3,
            '4' => 0x4,
            '5' => 0x5,
            '6' => 0x6,
            '7' => 0x7,
            '8' => 0x8,
            '9' => 0x9,
            'A' | 'a' => 0xA,
            'B' | 'b' => 0xB,
            'C' | 'c' => 0xC,
            'D' | 'd' => 0xD,
            'E' | 'e' => 0xE,
            'F' | 'f' => 0xF,
            _ => panic!("Unsupported character"),
        };
        converted.push(x);
    }
    let chunks = converted.chunks(2);
    let mut result: Vec<u8> = Vec::new();
    for chunk in chunks {
        result.push((chunk[0] << 4) + chunk[1]);
    }
    result
}
fn hash_to_vec ( hash : & str ) -> Vec < u8 > { let mut converted : Vec < u8 > = Vec :: new ( ) ; for char in hash . chars ( ) { // assume only hex compatible chars let x = match char { '0' => 0x0u8 , '1' => 0x1 , '2' => 0x2 , '3' => 0x3 , '4' => 0x4 , '5' => 0x5 , '6' => 0x6 , '7' => 0x7 , '8' => 0x8 , '9' => 0x9 , 'A' | 'a' => 0xA , 'B' | 'b' => 0xB , 'C' | 'c' => 0xC , 'D' | 'd' => 0xD , 'E' | 'e' => 0xE , 'F' | 'f' => 0xF , _ => panic ! ( " " ) , } ; converted . push ( x ) ; } let chunks = converted . chunks ( 2 ) ; let mut result : Vec < u8 > = Vec :: new ( ) ; for chunk in chunks { result . push ( ( chunk [ 0 ] << 4 ) + chunk [ 1 ] ) ; } result }
Convert an object hash to a vector for usable in the index file
Convert an object hash to a vector for usable in the index file
hash
&str
hash
&str