fn fuse_nibbles_node<'a>(nibbles: &'a [u8], leaf: bool) -> impl Iterator<Item = u8> + 'a {
	debug_assert!(nibbles.len() < 255 + 126, "nibbles length too long. what kind of size of key are you trying to include in the trie!?!");
	// We use two ranges of possible values; one for leafs and the other for extensions.
	// Each range encodes zero following nibbles up to some maximum. If the maximum is
	// reached, then it is considered "big" and a second byte follows it in order to
	// encode a further offset to the number of nibbles of up to 255. Beyond that, we
	// cannot encode. This shouldn't be a problem though since that allows for keys of
	// up to 380 nibbles (190 bytes) and we expect key sizes to be generally 128-bit (16
	// bytes) or, at a push, 384-bit (48 bytes).

	let (first_byte_small, big_threshold) = if leaf {
		(LEAF_NODE_OFFSET, (LEAF_NODE_BIG - LEAF_NODE_OFFSET) as usize)
	} else {
		(EXTENSION_NODE_OFFSET, (EXTENSION_NODE_BIG - EXTENSION_NODE_OFFSET) as usize)
	};
	let first_byte = first_byte_small + nibbles.len().min(big_threshold) as u8;
	once(first_byte)
		.chain(if nibbles.len() >= big_threshold { Some((nibbles.len() - big_threshold) as u8) } else { None })
		.chain(if nibbles.len() % 2 == 1 { Some(nibbles[0]) } else { None })
		.chain(nibbles[nibbles.len() % 2..].chunks(2).map(|ch| ch[0] << 4 | ch[1]))
}
/// Create a leaf/extension node, encoding a number of nibbles. Note that this
/// cannot handle a number of nibbles that is zero or greater than 127 and if
/// you attempt to do so *IT WILL PANIC*.
Create a leaf/extension node, encoding a number of nibbles. Note that this
cannot handle a number of nibbles that is zero or greater than 127 and if
you attempt to do so *IT WILL PANIC*.
Create a leaf / extension node encoding a number of nibbles . Note that this cannot handle a number of nibbles that is zero or greater than 127 and if you attempt to do so * IT WILL PANIC * .
fn fuse_nibbles_node<'a>(nibbles: &'a [u8], leaf: bool) -> impl Iterator<Item = u8> + 'a {
	debug_assert!(nibbles.len() < 255 + 126, "nibbles length too long. what kind of size of key are you trying to include in the trie!?!");
	// We use two ranges of possible values; one for leafs and the other for extensions.
	// Each range encodes zero following nibbles up to some maximum. If the maximum is
	// reached, then it is considered "big" and a second byte follows it in order to
	// encode a further offset to the number of nibbles of up to 255. Beyond that, we
	// cannot encode. This shouldn't be a problem though since that allows for keys of
	// up to 380 nibbles (190 bytes) and we expect key sizes to be generally 128-bit (16
	// bytes) or, at a push, 384-bit (48 bytes).
	let (first_byte_small, big_threshold) = if leaf {
		(LEAF_NODE_OFFSET, (LEAF_NODE_BIG - LEAF_NODE_OFFSET) as usize)
	} else {
		(EXTENSION_NODE_OFFSET, (EXTENSION_NODE_BIG - EXTENSION_NODE_OFFSET) as usize)
	};
	let first_byte = first_byte_small + nibbles.len().min(big_threshold) as u8;
	once(first_byte)
		.chain(if nibbles.len() >= big_threshold { Some((nibbles.len() - big_threshold) as u8) } else { None })
		.chain(if nibbles.len() % 2 == 1 { Some(nibbles[0]) } else { None })
		.chain(nibbles[nibbles.len() % 2..].chunks(2).map(|ch| ch[0] << 4 | ch[1]))
}
fn fuse_nibbles_node < ' a > ( nibbles : & ' a [ u8 ] , leaf : bool ) -> impl Iterator < Item = u8 > + ' a { debug_assert ! ( nibbles len ( ) 255 126 " " ) ; // We use two ranges of possible values; one for leafs and the other for extensions. // Each range encodes zero following nibbles up to some maximum. If the maximum is // reached, then it is considered "big" and a second byte follows it in order to // encode a further offset to the number of nibbles of up to 255. Beyond that, we // cannot encode. This shouldn't be a problem though since that allows for keys of // up to 380 nibbles (190 bytes) and we expect key sizes to be generally 128-bit (16 // bytes) or, at a push, 384-bit (48 bytes). let ( first_byte_small , big_threshold ) = if leaf { ( LEAF_NODE_OFFSET , ( LEAF_NODE_BIG - LEAF_NODE_OFFSET ) as usize ) } else { ( EXTENSION_NODE_OFFSET , ( EXTENSION_NODE_BIG - EXTENSION_NODE_OFFSET ) as usize ) } ; let first_byte = first_byte_small + nibbles . len ( ) . min ( big_threshold ) as u8 ; once ( first_byte ) . chain ( if nibbles . len ( ) >= big_threshold { Some ( ( nibbles . len ( ) - big_threshold ) as u8 ) } else { None } ) . chain ( if nibbles . len ( ) % 2 == 1 { Some ( nibbles [ 0 ] ) } else { None } ) . chain ( nibbles [ nibbles . len ( ) % 2 .. ] . chunks ( 2 ) . map ( | ch | ch [ 0 ] << 4 | ch [ 1 ] ) ) }
Create a leaf/extension node, encoding a number of nibbles.
Create a leaf / extension node encoding a number of nibbles .
nibbles
&'a [u8]
leaf
bool
nibbles
&'a [u8]
leaf
bool