lean_string/features/
arbitrary.rs1use crate::{LeanStr, LeanString};
2use arbitrary::{Arbitrary, Result, Unstructured};
3
4#[cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))]
5impl<'a> Arbitrary<'a> for LeanString {
6 fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
7 <&str as Arbitrary>::arbitrary(u).map(LeanString::from)
8 }
9
10 fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self> {
11 <&str as Arbitrary>::arbitrary_take_rest(u).map(LeanString::from)
12 }
13
14 fn size_hint(depth: usize) -> (usize, Option<usize>) {
15 <&str as Arbitrary>::size_hint(depth)
16 }
17}
18
19#[cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))]
20impl<'a> Arbitrary<'a> for LeanStr {
21 fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
22 <&str as Arbitrary>::arbitrary(u).map(LeanStr::from)
23 }
24
25 fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self> {
26 <&str as Arbitrary>::arbitrary_take_rest(u).map(LeanStr::from)
27 }
28
29 fn size_hint(depth: usize) -> (usize, Option<usize>) {
30 <&str as Arbitrary>::size_hint(depth)
31 }
32}