reset() method for FeedbackState
This commit is contained in:
parent
d136ee7427
commit
231caf0797
@ -132,9 +132,14 @@ where
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl<T> FeedbackState for MapFeedbackState<T> where
|
||||
T: Integer + Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned
|
||||
impl<T> FeedbackState for MapFeedbackState<T>
|
||||
where
|
||||
T: Integer + Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
|
||||
{
|
||||
fn reset(&mut self) -> Result<(), Error> {
|
||||
self.history_map.iter_mut().for_each(|x| *x = T::default());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Named for MapFeedbackState<T>
|
||||
|
@ -96,18 +96,33 @@ where
|
||||
|
||||
/// [`FeedbackState`] is the data associated with a [`Feedback`] that must persist as part
|
||||
/// of the fuzzer State
|
||||
pub trait FeedbackState: Named + serde::Serialize + serde::de::DeserializeOwned {}
|
||||
pub trait FeedbackState: Named + serde::Serialize + serde::de::DeserializeOwned {
|
||||
/// Reset the internal state
|
||||
fn reset(&mut self) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// A haskell-style tuple of feedback states
|
||||
pub trait FeedbackStatesTuple: MatchName + serde::Serialize + serde::de::DeserializeOwned {}
|
||||
pub trait FeedbackStatesTuple: MatchName + serde::Serialize + serde::de::DeserializeOwned {
|
||||
fn reset_all(&mut self) -> Result<(), Error>;
|
||||
}
|
||||
|
||||
impl FeedbackStatesTuple for () {}
|
||||
impl FeedbackStatesTuple for () {
|
||||
fn reset_all(&mut self) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<Head, Tail> FeedbackStatesTuple for (Head, Tail)
|
||||
where
|
||||
Head: FeedbackState,
|
||||
Tail: FeedbackStatesTuple,
|
||||
{
|
||||
fn reset_all(&mut self) -> Result<(), Error> {
|
||||
self.0.reset()?;
|
||||
self.1.reset_all()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CombinedFeedback<A, B, I, S, FL>
|
||||
|
Loading…
x
Reference in New Issue
Block a user