Skip to content

Commit

Permalink
Merge #7
Browse files Browse the repository at this point in the history
7: Relax Fn requirement, use FnOnce instead r=PaulGrandperrin a=g2p

This makes the fuzz macro and function usable in way more contexts.

Co-authored-by: Gabriel <[email protected]>
  • Loading branch information
bors[bot] and g2p committed Jun 9, 2018
2 parents 33bd4e4 + be317ed commit e8eddc6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ extern "C" {
/// ```
#[cfg(not(fuzzing))]
#[allow(unused_variables)]
pub fn fuzz<F>(closure: F) where F: Fn(&[u8]) {
pub fn fuzz<F>(closure: F) where F: FnOnce(&[u8]) {
eprintln!("This executable hasn't been built with \"cargo hfuzz\".");
eprintln!("Try executing \"cargo hfuzz build\" and check out \"hfuzz_target\" directory.");
eprintln!("Or execute \"cargo hfuzz run TARGET\"");
Expand All @@ -249,7 +249,7 @@ lazy_static! {
}

#[cfg(all(fuzzing, not(fuzzing_debug)))]
pub fn fuzz<F>(closure: F) where F: Fn(&[u8]) + std::panic::RefUnwindSafe {
pub fn fuzz<F>(closure: F) where F: FnOnce(&[u8]) + std::panic::UnwindSafe {
// sets panic hook if not already done
lazy_static::initialize(&PANIC_HOOK);

Expand Down Expand Up @@ -278,7 +278,7 @@ pub fn fuzz<F>(closure: F) where F: Fn(&[u8]) + std::panic::RefUnwindSafe {
}

#[cfg(all(fuzzing, fuzzing_debug))]
pub fn fuzz<F>(closure: F) where F: Fn(&[u8]) {
pub fn fuzz<F>(closure: F) where F: FnOnce(&[u8]) {
use std::env;
use std::fs::File;
use memmap::MmapOptions;
Expand Down

0 comments on commit e8eddc6

Please sign in to comment.