Skip to content

Commit

Permalink
moving from generic to associated type to reduce code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
riesentoaster committed Dec 11, 2024
1 parent aa59442 commit 9eea795
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 4 additions & 5 deletions libafl/src/mutators/havoc_mutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,10 @@ mod tests {
&self.vec
}
}
impl DefaultMutators<MappedHavocMutationsType<Self, MutVecInput<'static>, &'static [u8]>>
for CustomInput
{
fn default_mutators(
) -> MappedHavocMutationsType<Self, MutVecInput<'static>, &'static [u8]> {
impl DefaultMutators for CustomInput {
type Type = MappedHavocMutationsType<Self, MutVecInput<'static>, &'static [u8]>;

fn default_mutators() -> Self::Type {
mapped_havoc_mutations(Self::vec_mut, Self::vec)
}
}
Expand Down
6 changes: 4 additions & 2 deletions libafl/src/mutators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,10 @@ impl Named for NopMutator {
}

/// Extensions of [`crate::inputs::Input`]s that have default mutators
pub trait DefaultMutators<MT> {
pub trait DefaultMutators {
/// The resulting mutator list type
type Type;
/// Get the default mutators for this type
#[must_use]
fn default_mutators() -> MT;
fn default_mutators() -> Self::Type;
}

0 comments on commit 9eea795

Please sign in to comment.