fix some docs and use slice::fill instead of manual implementation (#1467)

* update documentation of `MinimizerScheduler`

(convert a few references to types into doc links and update the docs of `on_remove`)

* replace manual implementation of `slice::fill`

the in the code comment linked stackoverflow comment https://stackoverflow.com/a/51732799/1345238/
now mentions `slice::fill`
it seems to compile to the same thing as the old version https://rust.godbolt.org/z/98Y4x97vY

* fix docs for the `*InterestingMutator`s and `*ByteAddMutator`s

the macros didn't previously docs gens didn't previously
 generate fitting docs
This commit is contained in:
lenawanel 2023-08-27 23:11:44 +02:00 committed by GitHub
parent 713f0c5913
commit 6a2d6fa66d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View File

@ -50,9 +50,7 @@ pub(crate) unsafe fn buffer_copy<T>(dst: &mut [T], src: &[T], from: usize, to: u
#[inline]
pub fn buffer_set<T: Clone>(data: &mut [T], from: usize, len: usize, val: T) {
debug_assert!(from + len <= data.len());
for p in &mut data[from..(from + len)] {
*p = val.clone();
}
data[from..(from + len)].fill(val);
}
/// Generate a range of values where (upon repeated calls) each index is likely to appear in the
@ -353,7 +351,7 @@ impl ByteRandMutator {
// within the input are treated as u8, u16, u32, or u64, then mutated in place.
macro_rules! add_mutator_impl {
($name: ident, $size: ty) => {
/// Adds or subtracts a random value up to `ARITH_MAX` to a [`<$size>`] at a random place in the [`Vec`], in random byte order.
#[doc = concat!("Adds or subtracts a random value up to `ARITH_MAX` to a [`", stringify!($size), "`] at a random place in the [`Vec`], in random byte order.")]
#[derive(Default, Debug)]
pub struct $name;
@ -402,7 +400,7 @@ macro_rules! add_mutator_impl {
}
impl $name {
/// Creates a new [`$name`].
#[doc = concat!("Creates a new [`", stringify!($name), "`].")]
#[must_use]
pub fn new() -> Self {
Self
@ -460,7 +458,7 @@ macro_rules! interesting_mutator_impl {
}
impl $name {
/// Creates a new [`$name`].
#[doc = concat!("Creates a new [`", stringify!($name), "`].")]
#[must_use]
pub fn new() -> Self {
Self

View File

@ -101,7 +101,7 @@ where
self.update_score(state, idx)
}
/// Removes an entry from the corpus, returning M if M was present.
/// Removes an entry from the corpus
fn on_remove(
&mut self,
state: &mut CS::State,
@ -252,7 +252,7 @@ where
M: AsSlice<Entry = usize> + SerdeAny + HasRefCnt,
CS::State: HasCorpus + HasMetadata + HasRand,
{
/// Update the `Corpus` score using the `MinimizerScheduler`
/// Update the [`Corpus`] score using the [`MinimizerScheduler`]
#[allow(clippy::unused_self)]
#[allow(clippy::cast_possible_wrap)]
pub fn update_score(&self, state: &mut CS::State, idx: CorpusId) -> Result<(), Error> {
@ -327,7 +327,7 @@ where
Ok(())
}
/// Cull the `Corpus` using the `MinimizerScheduler`
/// Cull the [`Corpus`] using the [`MinimizerScheduler`]
#[allow(clippy::unused_self)]
pub fn cull(&self, state: &CS::State) -> Result<(), Error> {
let Some(top_rated) = state.metadata_map().get::<TopRatedsMetadata>() else {