fn crc<'a, T: Iterator<Item = &'a u8>>(data: T) -> u32 {
    fn shift_left(val: u32) -> (u32, bool) {
        let carry = (val & (1 << 31)) != 0;
        (val << 1, carry)
    }

    // The actual CRC remainder is stored in the three most significant bytes
    // of crc. The least significant byte holds the next byte of the message to
    // be shifted through the CRC.
    let mut crc: u32 = 0;

    for byte in data {
        // Set up the next byte in the holding area...
        crc |= u32::from(*byte);

        // ...and shift it through the CRC (assuming an 8-bit byte).
        for _ in 0..8 {
            crc = match shift_left(crc) {
                (crc, false) => crc,
                (crc, true) => crc ^ (CRC_POLYNOMIAL << 8),
            };
        }
    }

    // Extract the remainder (assuming an 8-bit byte).
    crc >> 8
}
/// Calculates the sum of data passed through the 24-bit CRC. The sum will reside in the least
/// significant bytes of the returned `u32`.
Calculates the sum of data passed through the 24-bit CRC. The sum will reside in the least
significant bytes of the returned `u32`.
Calculates the sum of data passed through the 24 - bit CRC . The sum will reside in the least significant bytes of the returned ` u32 ` .
fn crc<'a, T: Iterator<Item = &'a u8>>(data: T) -> u32 {
    fn shift_left(val: u32) -> (u32, bool) {
        let carry = (val & (1 << 31)) != 0;
        (val << 1, carry)
    }
    // The actual CRC remainder is stored in the three most significant bytes
    // of crc. The least significant byte holds the next byte of the message to
    // be shifted through the CRC.
    let mut crc: u32 = 0;
    for byte in data {
        // Set up the next byte in the holding area...
        crc |= u32::from(*byte);
        // ...and shift it through the CRC (assuming an 8-bit byte).
        for _ in 0..8 {
            crc = match shift_left(crc) {
                (crc, false) => crc,
                (crc, true) => crc ^ (CRC_POLYNOMIAL << 8),
            };
        }
    }
    // Extract the remainder (assuming an 8-bit byte).
    crc >> 8
}
fn crc < ' a , T : Iterator < Item = & ' a u8 > > ( data : T ) -> u32 { fn shift_left ( val : u32 ) -> ( u32 , bool ) { let carry = ( val & ( 1 << 31 ) ) != 0 ; ( val << 1 , carry ) } // The actual CRC remainder is stored in the three most significant bytes // of crc. The least significant byte holds the next byte of the message to // be shifted through the CRC. let mut crc : u32 = 0 ; for byte in data { // Set up the next byte in the holding area... crc |= u32 :: from ( * byte ) ; // ...and shift it through the CRC (assuming an 8-bit byte). for _ in 0 .. 8 { crc = match shift_left ( crc ) { ( crc , false ) => crc , ( crc , true ) => crc ^ ( CRC_POLYNOMIAL << 8 ) , } ; } } // Extract the remainder (assuming an 8-bit byte). crc >> 8 }
Calculates the sum of data passed through the 24-bit CRC.
Calculates the sum of data passed through the 24 - bit CRC .
data
T
data
T