arbitrary/foreign/core/bool.rs
1use crate::{Arbitrary, Result, Unstructured};
2
3/// Returns false, not an error, if this `Unstructured` [is empty][Unstructured::is_empty].
4impl<'a> Arbitrary<'a> for bool {
5 fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
6 Ok(<u8 as Arbitrary<'a>>::arbitrary(u)? & 1 == 1)
7 }
8
9 #[inline]
10 fn size_hint(depth: usize) -> (usize, Option<usize>) {
11 <u8 as Arbitrary<'a>>::size_hint(depth)
12 }
13}