Remove FilterLinksIter

Because the code is not used.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-04-13 22:16:32 +02:00
parent 1f515b1d0d
commit 4afebbe9e4

View file

@ -237,38 +237,6 @@ pub mod iter {
GetIter(i, store) GetIter(i, store)
} }
/// Turn this iterator into a FilterLinksIter that removes all entries that are not linked
/// to any other entry, by filtering them out the iterator.
///
/// This does _not_ remove the entries from the store.
pub fn without_unlinked(self) -> FilterLinksIter<'a> {
FilterLinksIter::new(self, Box::new(|links: &[Link]| links.len() > 0))
}
/// Turn this iterator into a FilterLinksIter that removes all entries that have less than
/// `n` links to any other entries.
///
/// This does _not_ remove the entries from the store.
pub fn with_less_than_n_links(self, n: usize) -> FilterLinksIter<'a> {
FilterLinksIter::new(self, Box::new(move |links: &[Link]| links.len() < n))
}
/// Turn this iterator into a FilterLinksIter that removes all entries that have more than
/// `n` links to any other entries.
///
/// This does _not_ remove the entries from the store.
pub fn with_more_than_n_links(self, n: usize) -> FilterLinksIter<'a> {
FilterLinksIter::new(self, Box::new(move |links: &[Link]| links.len() > n))
}
/// Turn this iterator into a FilterLinksIter that removes all entries where the predicate
/// `F` returns false
///
/// This does _not_ remove the entries from the store.
pub fn filtered_for_links(self, f: Box<Fn(&[Link]) -> bool>) -> FilterLinksIter<'a> {
FilterLinksIter::new(self, f)
}
pub fn store(&self) -> &Store { pub fn store(&self) -> &Store {
self.1 self.1
} }
@ -287,46 +255,6 @@ pub mod iter {
} }
/// An iterator helper that has a function F.
///
/// If the function F returns `false` for the number of links, the entry is ignored, else it is
/// taken.
pub struct FilterLinksIter<'a>(GetIter<'a>, Box<Fn(&[Link]) -> bool>);
impl<'a> FilterLinksIter<'a> {
pub fn new(gi: GetIter<'a>, f: Box<Fn(&[Link]) -> bool>) -> FilterLinksIter<'a> {
FilterLinksIter(gi, f)
}
}
impl<'a> Iterator for FilterLinksIter<'a> {
type Item = Result<FileLockEntry<'a>>;
fn next(&mut self) -> Option<Self::Item> {
use internal::InternalLinker;
loop {
match self.0.next() {
Some(Ok(fle)) => {
let links = match fle.get_internal_links() {
Err(e) => return Some(Err(e)),
Ok(links) => links.collect::<Vec<_>>(),
};
if !(self.1)(&links) {
continue;
} else {
return Some(Ok(fle));
}
},
Some(Err(e)) => return Some(Err(e)),
None => break,
}
}
None
}
}
} }
impl InternalLinker for Entry { impl InternalLinker for Entry {