pub trait Shrink {
fn shrink(source: Vec<u8>) -> Self;
fn next(&mut self) -> &[u8];
#[must_use = "The shrunk test case must be handled"]
fn report(&mut self, report: ShrinkReport) -> Option<&[u8]>;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum ShrinkReport {
Pass,
Fail,
}
impl ShrinkReport {
pub fn is_pass(&self) -> bool {
matches!(self, Self::Pass)
}
pub fn is_fail(&self) -> bool {
matches!(self, Self::Fail)
}
}
impl<T> From<std::thread::Result<T>> for ShrinkReport {
fn from(res: std::thread::Result<T>) -> Self {
match res {
Ok(_) => ShrinkReport::Pass,
Err(_) => ShrinkReport::Fail,
}
}
}