Add remove_from_all method to Corpus
trait (#2259)
* add remove_from_all * a * a * aaaaaaa * make remove_from_all to remove
This commit is contained in:
parent
b96b9be674
commit
e912216a37
@ -107,9 +107,8 @@ where
|
|||||||
self.inner.replace(idx, testcase)
|
self.inner.replace(idx, testcase)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes an entry from the corpus, returning it if it was present.
|
/// Removes an entry from the corpus, returning it if it was present; considers both enabled and disabled testcases.
|
||||||
#[inline]
|
fn remove(&mut self, idx: CorpusId) -> Result<Testcase<Self::Input>, Error> {
|
||||||
fn remove(&mut self, idx: CorpusId) -> Result<Testcase<I>, Error> {
|
|
||||||
let testcase = self.inner.remove(idx)?;
|
let testcase = self.inner.remove(idx)?;
|
||||||
self.cached_indexes.borrow_mut().retain(|e| *e != idx);
|
self.cached_indexes.borrow_mut().retain(|e| *e != idx);
|
||||||
Ok(testcase)
|
Ok(testcase)
|
||||||
|
@ -396,12 +396,14 @@ where
|
|||||||
.ok_or_else(|| Error::key_not_found(format!("Index {idx} not found")))
|
.ok_or_else(|| Error::key_not_found(format!("Index {idx} not found")))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes an entry from the corpus, returning it if it was present.
|
/// Removes an entry from the corpus, returning it if it was present; considers both enabled and disabled testcases
|
||||||
#[inline]
|
#[inline]
|
||||||
fn remove(&mut self, idx: CorpusId) -> Result<Testcase<I>, Error> {
|
fn remove(&mut self, idx: CorpusId) -> Result<Testcase<Self::Input>, Error> {
|
||||||
self.storage
|
let mut testcase = self.storage.enabled.remove(idx);
|
||||||
.enabled
|
if testcase.is_none() {
|
||||||
.remove(idx)
|
testcase = self.storage.disabled.remove(idx);
|
||||||
|
}
|
||||||
|
testcase
|
||||||
.map(|x| x.take())
|
.map(|x| x.take())
|
||||||
.ok_or_else(|| Error::key_not_found(format!("Index {idx} not found")))
|
.ok_or_else(|| Error::key_not_found(format!("Index {idx} not found")))
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ where
|
|||||||
Ok(entry)
|
Ok(entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes an entry from the corpus, returning it if it was present.
|
/// Removes an entry from the corpus, returning it if it was present; considers both enabled and disabled corpus
|
||||||
#[inline]
|
#[inline]
|
||||||
fn remove(&mut self, idx: CorpusId) -> Result<Testcase<I>, Error> {
|
fn remove(&mut self, idx: CorpusId) -> Result<Testcase<I>, Error> {
|
||||||
let entry = self.inner.remove(idx)?;
|
let entry = self.inner.remove(idx)?;
|
||||||
|
@ -113,7 +113,7 @@ pub trait Corpus: UsesInput + Serialize + for<'de> Deserialize<'de> {
|
|||||||
testcase: Testcase<Self::Input>,
|
testcase: Testcase<Self::Input>,
|
||||||
) -> Result<Testcase<Self::Input>, Error>;
|
) -> Result<Testcase<Self::Input>, Error>;
|
||||||
|
|
||||||
/// Removes an entry from the corpus, returning it if it was present.
|
/// Removes an entry from the corpus, returning it if it was present; considers both enabled and disabled testcases
|
||||||
fn remove(&mut self, id: CorpusId) -> Result<Testcase<Self::Input>, Error>;
|
fn remove(&mut self, id: CorpusId) -> Result<Testcase<Self::Input>, Error>;
|
||||||
|
|
||||||
/// Get by id; considers only enabled testcases
|
/// Get by id; considers only enabled testcases
|
||||||
|
@ -63,7 +63,7 @@ where
|
|||||||
Err(Error::unsupported("Unsupported by NopCorpus"))
|
Err(Error::unsupported("Unsupported by NopCorpus"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes an entry from the corpus, returning it if it was present.
|
/// Removes an entry from the corpus, returning it if it was present; considers both enabled and disabled testcases
|
||||||
#[inline]
|
#[inline]
|
||||||
fn remove(&mut self, _idx: CorpusId) -> Result<Testcase<I>, Error> {
|
fn remove(&mut self, _idx: CorpusId) -> Result<Testcase<I>, Error> {
|
||||||
Err(Error::unsupported("Unsupported by NopCorpus"))
|
Err(Error::unsupported("Unsupported by NopCorpus"))
|
||||||
|
@ -112,7 +112,7 @@ where
|
|||||||
self.inner.peek_free_id()
|
self.inner.peek_free_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes an entry from the corpus, returning it if it was present.
|
/// Removes an entry from the corpus, returning it if it was present; considers both enabled and disabled testcases
|
||||||
#[inline]
|
#[inline]
|
||||||
fn remove(&mut self, idx: CorpusId) -> Result<Testcase<I>, Error> {
|
fn remove(&mut self, idx: CorpusId) -> Result<Testcase<I>, Error> {
|
||||||
self.inner.remove(idx)
|
self.inner.remove(idx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user