Skip to content

Commit

Permalink
Implement FeedbackFactory for {Const,Not}Feedback (#2478)
Browse files Browse the repository at this point in the history
* libafl: Impl FeedbackFactory for NotFeedback

* libafl: Impl FeedbackFactory for ConstFeedback
  • Loading branch information
dergoegge authored Aug 9, 2024
1 parent 9b32f85 commit 799c634
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libafl/src/feedbacks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,16 @@ where
}
}

impl<A, S, T> FeedbackFactory<NotFeedback<A, S>, T> for NotFeedback<A, S>
where
A: Feedback<S> + FeedbackFactory<A, T>,
S: State,
{
fn create_feedback(&self, ctx: &T) -> NotFeedback<A, S> {
NotFeedback::new(self.first.create_feedback(ctx))
}
}

impl<A, S> NotFeedback<A, S>
where
A: Feedback<S>,
Expand Down Expand Up @@ -1279,6 +1289,12 @@ impl From<ConstFeedback> for bool {
}
}

impl<T> FeedbackFactory<ConstFeedback, T> for ConstFeedback {
fn create_feedback(&self, _ctx: &T) -> ConstFeedback {
*self
}
}

#[cfg(feature = "track_hit_feedbacks")]
/// Error if [`Feedback::last_result`] is called before the `Feedback` is actually run.
pub(crate) fn premature_last_result_err() -> Error {
Expand Down

0 comments on commit 799c634

Please sign in to comment.