mod coded;
mod composite;
mod strings;
#[allow(unused_macros)]
macro_rules! arb_via_code {
($($ty:path),* $(,)?) => { $(
impl<'a> ::arbitrary::Arbitrary<'a> for $ty {
fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result<Self> {
Ok(<$ty>::from_u32(<u32 as ::arbitrary::Arbitrary>::arbitrary(u)?))
}
}
)* };
}
#[allow(unused_imports)]
pub(crate) use arb_via_code;
#[allow(unused_macros)]
macro_rules! arb_via_named_variants {
($ty:path, [$($variant:ident),+ $(,)?]) => {
impl<'a> ::arbitrary::Arbitrary<'a> for $ty {
fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result<Self> {
const NAMED: &[$ty] = &[$(<$ty>::$variant),+];
Ok(*u.choose(NAMED)?)
}
}
};
}
#[allow(unused_imports)]
pub(crate) use arb_via_named_variants;
#[allow(unused_macros)]
macro_rules! arb_open_string_enum {
($ty:path, [$($slug:literal),+ $(,)?]) => {
impl<'a> ::arbitrary::Arbitrary<'a> for $ty {
fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result<Self> {
const SAMPLES: &[&str] = &[$($slug),+];
if <bool as ::arbitrary::Arbitrary>::arbitrary(u)? {
Ok(<$ty as ::core::str::FromStr>::from_str(u.choose(SAMPLES)?).unwrap())
} else {
let s = <::std::string::String as ::arbitrary::Arbitrary>::arbitrary(u)?;
Ok(<$ty as ::core::str::FromStr>::from_str(&s).unwrap())
}
}
}
};
}
#[allow(unused_imports)]
pub(crate) use arb_open_string_enum;
#[cfg(test)]
mod tests;