Function cookie_factory::multi::many_ref

source ·
pub fn many_ref<E, It, I, F, G, O: Write>(
    items: I,
    generator: F
) -> impl SerializeFn<O>
where It: Iterator<Item = E> + Clone, I: IntoIterator<Item = E, IntoIter = It>, F: Fn(E) -> G, G: SerializeFn<O>,
Expand description

Applies a generator over an iterator of values, and applies the serializers generated

use cookie_factory::{gen, multi::many_ref, combinator::string};

let mut buf = [0u8; 100];

let data = vec!["abcd", "efgh", "ijkl"];
{
  let (buf, pos) = gen(many_ref(&data, string), &mut buf[..]).unwrap();
  assert_eq!(pos, 12);
  assert_eq!(buf.len(), 100 - 12);
}

assert_eq!(&buf[..12], &b"abcdefghijkl"[..]);