Skip to content

Commit c8fedd2

Browse files
committed
Update the arbitrary example in the docs for arbitrary 1.0
1 parent 84e5ca2 commit c8fedd2

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/lib.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
8484
///
8585
/// ```no_run
8686
/// #![no_main]
87+
/// # mod foo {
8788
///
88-
/// use libfuzzer_sys::{arbitrary::{Arbitrary, Unstructured}, fuzz_target};
89+
/// use libfuzzer_sys::{arbitrary::{Arbitrary, Error, Unstructured}, fuzz_target};
8990
///
9091
/// #[derive(Debug)]
9192
/// pub struct Rgb {
@@ -94,11 +95,8 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
9495
/// b: u8,
9596
/// }
9697
///
97-
/// impl Arbitrary for Rgb {
98-
/// fn arbitrary<U>(raw: &mut U) -> Result<Self, U::Error>
99-
/// where
100-
/// U: Unstructured + ?Sized
101-
/// {
98+
/// impl<'a> Arbitrary<'a> for Rgb {
99+
/// fn arbitrary(raw: &mut Unstructured<'a>) -> Result<Self, Error> {
102100
/// let mut buf = [0; 3];
103101
/// raw.fill_buffer(&mut buf)?;
104102
/// let r = buf[0];
@@ -112,7 +110,12 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
112110
/// fuzz_target!(|color: Rgb| {
113111
/// my_crate::convert_color(color);
114112
/// });
115-
/// # mod my_crate { fn convert_color(_: super::Rgb) {} }
113+
/// # mod my_crate {
114+
/// # use super::Rgb;
115+
/// # pub fn convert_color(_: Rgb) {}
116+
/// # }
117+
/// # }
118+
/// ```
116119
#[macro_export]
117120
macro_rules! fuzz_target {
118121
(|$bytes:ident| $body:block) => {

0 commit comments

Comments
 (0)