pub fn deflate_immediate<I: Iterator<Item=u8>>(input:I) -> Vec<u8> {
	let input:Vec<u8> = input.collect();
	let input = input.chunks(0xFFFF);

	let last_item = input.len() - 1;
	let input = input.zip(0..).map(|(chunk, idx)| (chunk, idx == last_item));
	// I'd love to use an Iterator::flat_map here, but I can't figure out how to get the slices in the flat_map to live long enough
	let mut retval:Vec<u8> = Vec::new();
	for (chunk, is_last) in input {
		retval.push(u8::from(is_last));
		retval.extend((chunk.len() as u16).to_le_bytes().iter());
		retval.extend((!(chunk.len() as u16)).to_le_bytes().iter());
		retval.extend(chunk.iter());
	}
	retval
}
/// Store the the input in a deflate stream entirely using immediate mode (00)
Store the the input in a deflate stream entirely using immediate mode (00)
Store the the input in a deflate stream entirely using immediate mode ( 00 )
pub fn deflate_immediate<I: Iterator<Item=u8>>(input:I) -> Vec<u8> {
	let input:Vec<u8> = input.collect();
	let input = input.chunks(0xFFFF);
	let last_item = input.len() - 1;
	let input = input.zip(0..).map(|(chunk, idx)| (chunk, idx == last_item));
	// I'd love to use an Iterator::flat_map here, but I can't figure out how to get the slices in the flat_map to live long enough
	let mut retval:Vec<u8> = Vec::new();
	for (chunk, is_last) in input {
		retval.push(u8::from(is_last));
		retval.extend((chunk.len() as u16).to_le_bytes().iter());
		retval.extend((!(chunk.len() as u16)).to_le_bytes().iter());
		retval.extend(chunk.iter());
	}
	retval
}
pub fn deflate_immediate < I : Iterator < Item = u8 > > ( input : I ) -> Vec < u8 > { let input : Vec < u8 > = input . collect ( ) ; let input = input . chunks ( 0xFFFF ) ; let last_item = input . len ( ) - 1 ; let input = input . zip ( 0 .. ) . map ( | ( chunk , idx ) | ( chunk , idx == last_item ) ) ; // I'd love to use an Iterator::flat_map here, but I can't figure out how to get the slices in the flat_map to live long enough let mut retval : Vec < u8 > = Vec :: new ( ) ; for ( chunk , is_last ) in input { retval . push ( u8 :: from ( is_last ) ) ; retval . extend ( ( chunk . len ( ) as u16 ) . to_le_bytes ( ) . iter ( ) ) ; retval . extend ( ( ! ( chunk . len ( ) as u16 ) ) . to_le_bytes ( ) . iter ( ) ) ; retval . extend ( chunk . iter ( ) ) ; } retval }
Store the the input in a deflate stream entirely using immediate mode (00)
Store the the input in a deflate stream entirely using immediate mode ( 00 )
input
I