[][src]Function cookie_factory::slice

pub fn slice<S: AsRef<[u8]>, W: Write>(data: S) -> impl SerializeFn<W>

Writes a byte slice to the output

use cookie_factory::slice;

let mut buf = [0u8; 100];

{
  let buf = slice(&b"abcd"[..])(&mut buf[..]).unwrap();
  assert_eq!(buf.len(), 100 - 4);
}

assert_eq!(&buf[..4], &b"abcd"[..]);