From 9eea795594a1e3c3664cea923d404c743a212fbb Mon Sep 17 00:00:00 2001 From: Valentin Huber Date: Tue, 8 Oct 2024 22:37:30 +0200 Subject: [PATCH] moving from generic to associated type to reduce code duplication --- libafl/src/mutators/havoc_mutations.rs | 9 ++++----- libafl/src/mutators/mod.rs | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libafl/src/mutators/havoc_mutations.rs b/libafl/src/mutators/havoc_mutations.rs index 2da7d1a5d3..1ddf945c42 100644 --- a/libafl/src/mutators/havoc_mutations.rs +++ b/libafl/src/mutators/havoc_mutations.rs @@ -285,11 +285,10 @@ mod tests { &self.vec } } - impl DefaultMutators, &'static [u8]>> - for CustomInput - { - fn default_mutators( - ) -> MappedHavocMutationsType, &'static [u8]> { + impl DefaultMutators for CustomInput { + type Type = MappedHavocMutationsType, &'static [u8]>; + + fn default_mutators() -> Self::Type { mapped_havoc_mutations(Self::vec_mut, Self::vec) } } diff --git a/libafl/src/mutators/mod.rs b/libafl/src/mutators/mod.rs index ff609fc374..5219ae4e23 100644 --- a/libafl/src/mutators/mod.rs +++ b/libafl/src/mutators/mod.rs @@ -399,8 +399,10 @@ impl Named for NopMutator { } /// Extensions of [`crate::inputs::Input`]s that have default mutators -pub trait DefaultMutators { +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; }