• Home
  • Raw
  • Download

Lines Matching full:arbitrary

11 use crate::{Arbitrary, Error, Result};
18 /// An `Unstructured` helps `Arbitrary` implementations interpret raw data
20 /// construct the `Arbitrary` type. The goal is that a small change to the "DNA
22 /// change to the generated `Arbitrary` instance. This helps a fuzzer
23 /// efficiently explore the `Arbitrary`'s input space.
32 /// a custom `Arbitrary` implementation by hand, instead of deriving it. Mostly,
33 /// you should just be passing it through to nested `Arbitrary::arbitrary`
43 /// using that to generate an arbitrary RGB color might look like:
47 /// use arbitrary::{Arbitrary, Unstructured};
50 /// #[derive(Arbitrary)]
65 /// if let Ok(rgb) = Rgb::arbitrary(&mut unstructured) {
81 /// use arbitrary::Unstructured;
95 /// use arbitrary::{Arbitrary, Unstructured};
104 /// let _ = bool::arbitrary(&mut u);
119 /// use arbitrary::{Arbitrary, Unstructured};
128 /// let _ = u32::arbitrary(&mut u);
136 /// Generate an arbitrary instance of `A`.
139 /// Arbitrary>::arbitrary(self)`. This helper is a little bit more concise,
146 /// # #[cfg(feature="derive")] fn foo() -> arbitrary::Result<()> {
147 /// use arbitrary::{Arbitrary, Unstructured};
149 /// #[derive(Arbitrary)]
163 /// let value = u.arbitrary()?;
167 pub fn arbitrary<A>(&mut self) -> Result<A> in arbitrary() method
169 A: Arbitrary<'a>, in arbitrary()
171 <A as Arbitrary<'a>>::arbitrary(self) in arbitrary()
175 /// arbitrary `ElementType`s.
178 /// Arbitrary>::size_hint`][crate::Arbitrary::size_hint] method to smartly
180 /// construct that many arbitrary `ElementType`s.
182 /// This should only be called within an `Arbitrary` implementation.
187 /// use arbitrary::{Arbitrary, Result, Unstructured};
194 /// impl<'a, T> Arbitrary<'a> for MyCollection<T>
196 /// T: Arbitrary<'a>,
198 /// fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
205 /// let element = T::arbitrary(u)?;
215 ElementType: Arbitrary<'a>, in arbitrary_len()
218 let (lower, upper) = <ElementType as Arbitrary>::size_hint(0); in arbitrary_len()
283 /// use arbitrary::{Arbitrary, Unstructured};
313 "`arbitrary::Unstructured::int_in_range` requires a non-empty range" in int_in_range_impl()
331 // Compute an arbitrary integer offset from the start of the range. We in int_in_range_impl()
333 // arbitrary integer and then clamping that int into our range bounds in int_in_range_impl()
347 // Combine this byte into our arbitrary integer, but avoid in int_in_range_impl()
376 /// This should only be used inside of `Arbitrary` implementations.
386 /// use arbitrary::Unstructured;
399 /// use arbitrary::Unstructured;
419 /// Using Fisher–Yates shuffle shuffle to gerate an arbitrary permutation.
424 /// use arbitrary::Unstructured;
441 /// use arbitrary::Unstructured;
471 /// # fn foo() -> arbitrary::Result<()> {
472 /// use arbitrary::Unstructured;
495 /// This should only be called within an `Arbitrary` implementation. This is
497 /// `Arbitrary` implementations like `<Vec<u8>>::arbitrary` and
498 /// `String::arbitrary` over using this method directly.
506 /// use arbitrary::Unstructured;
533 /// This should only be called within an `Arbitrary` implementation. This is
535 /// `Arbitrary` implementations like `<Vec<u8>>::arbitrary` and
536 /// `String::arbitrary` over using this method directly.
541 /// use arbitrary::Unstructured;
568 /// use arbitrary::Unstructured;
590 /// use arbitrary::Unstructured;
604 /// This is useful for implementing [`Arbitrary::arbitrary`] on collections
606 pub fn arbitrary_iter<'b, ElementType: Arbitrary<'a>>( in arbitrary_iter()
618 /// This is useful for implementing [`Arbitrary::arbitrary_take_rest`] on collections
620 pub fn arbitrary_take_rest_iter<ElementType: Arbitrary<'a>>( in arbitrary_take_rest_iter()
635 /// Call the given function an arbitrary number of times.
638 /// generate arbitrary data and structures.
653 /// Call a closure that generates an arbitrary type inside a context an
654 /// arbitrary number of times:
657 /// use arbitrary::{Result, Unstructured};
724 impl<'a, 'b, ElementType: Arbitrary<'a>> Iterator for ArbitraryIter<'a, 'b, ElementType> {
727 let keep_going = self.u.arbitrary().unwrap_or(false); in next()
729 Some(Arbitrary::arbitrary(self.u)) in next()
743 impl<'a, ElementType: Arbitrary<'a>> Iterator for ArbitraryTakeRestIter<'a, ElementType> {
748 Some(Arbitrary::arbitrary_take_rest(u)) in next()
753 let ret = Arbitrary::arbitrary(&mut u); in next()