Function bytepad

Source
pub fn bytepad<'a, const W: usize, I>(
    s: I,
) -> BytePad<'a, W, <I as IntoIterator>::IntoIter> 
where I: IntoIterator<Item = EncodedString<'a>>,
Expand description

Prepends the integer encoding of W to s, then pads the result to a multiple of W for a non-zero W.

§Example

use sha3_utils::{bytepad, encode_string};

let v = bytepad::<32, _>([encode_string(b"hello, world!")]);
assert_eq!(
    v.flat_map(|v| v.as_bytes().to_vec()).collect::<Vec<_>>(),
    &[
        1, 32,
        1, 104,
        104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    ],
);

let v = bytepad::<32, _>([
    encode_string(b"hello, world!"),
    encode_string(b"hello, world!"),
]);
assert_eq!(
    v.flat_map(|v| v.as_bytes().to_vec()).collect::<Vec<_>>(),
    &[
        1, 32,
        1, 104,
        104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33,
        1, 104,
        104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33,
    ],
);