Function cookie_factory::sequence::pair

source ·
pub fn pair<F, G, W: Write>(first: F, second: G) -> impl SerializeFn<W>
where F: SerializeFn<W>, G: SerializeFn<W>,
Expand description

Applies 2 serializers in sequence

use cookie_factory::{gen, sequence::pair, combinator::string};

let mut buf = [0u8; 100];

{
  let (buf, pos) = gen(pair(string("abcd"), string("efgh")), &mut buf[..]).unwrap();
  assert_eq!(pos, 8);
  assert_eq!(buf.len(), 100 - 8);
}

assert_eq!(&buf[..8], &b"abcdefgh"[..]);