pub fn interleave_byte_blocks(separated: &mut [u8]) {
        // TODO rustify
        // TODO without extra allocation!
        let mut interleaved = Vec::with_capacity(separated.len());
        let (first_half, second_half) = separated
            .split_at((separated.len() + 1) / 2);

        let mut second_half_index = 0;
        let mut first_half_index = 0;

        loop {
            if interleaved.len() < separated.len() {
                interleaved.push(first_half[first_half_index]); // index unsafe but handled with care and unit-tested
                first_half_index += 1;
            } else { break; }

            if interleaved.len() < separated.len() {
                interleaved.push(second_half[second_half_index]); // index unsafe but handled with care and unit-tested
                second_half_index += 1;
            } else { break; }
        }

        separated.copy_from_slice(interleaved.as_slice())
    }
/// Interleave the bytes such that the second halv of the array is each other byte.
Interleave the bytes such that the second halv of the array is each other byte.
Interleave the bytes such that the second halv of the array is each other byte .
pub fn interleave_byte_blocks(separated: &mut [u8]) {
        // TODO rustify
        // TODO without extra allocation!
        let mut interleaved = Vec::with_capacity(separated.len());
        let (first_half, second_half) = separated
            .split_at((separated.len() + 1) / 2);
        let mut second_half_index = 0;
        let mut first_half_index = 0;
        loop {
            if interleaved.len() < separated.len() {
                interleaved.push(first_half[first_half_index]); // index unsafe but handled with care and unit-tested
                first_half_index += 1;
            } else { break; }
            if interleaved.len() < separated.len() {
                interleaved.push(second_half[second_half_index]); // index unsafe but handled with care and unit-tested
                second_half_index += 1;
            } else { break; }
        }
        separated.copy_from_slice(interleaved.as_slice())
    }
pub fn interleave_byte_blocks ( separated : & mut [ u8 ] ) { // TODO rustify // TODO without extra allocation! let mut interleaved = Vec :: with_capacity ( separated . len ( ) ) ; let ( first_half , second_half ) = separated . split_at ( ( separated . len ( ) + 1 ) / 2 ) ; let mut second_half_index = 0 ; let mut first_half_index = 0 ; loop { if interleaved . len ( ) < separated . len ( ) { interleaved . push ( first_half [ first_half_index ] ) ; // index unsafe but handled with care and unit-tested first_half_index += 1 ; } else { break ; } if interleaved . len ( ) < separated . len ( ) { interleaved . push ( second_half [ second_half_index ] ) ; // index unsafe but handled with care and unit-tested second_half_index += 1 ; } else { break ; } } separated . copy_from_slice ( interleaved . as_slice ( ) ) }
Interleave the bytes such that the second halv of the array is each other byte.
Interleave the bytes such that the second halv of the array is each other byte .
separated
&mut [u8]
separated
&mut [u8]