smol-bytes 0.1.6

High-performance, clone-efficient byte buffers optimized for small data.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use arbitrary::Arbitrary;

use super::{Buffer, INLINE_CAP};

impl<'a> Arbitrary<'a> for Buffer {
  fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
    let num = u.int_in_range(0..=INLINE_CAP)?;
    let mut buf = Buffer::new();
    for _ in 0..num {
      buf.put_bytes(u.arbitrary()?, 1);
    }
    Ok(buf)
  }
}