Add SelectExternal LinkIter extension trait

This commit is contained in:
Matthias Beyer 2016-10-15 15:20:36 +02:00
parent 647f25a904
commit 4ca501c03e

View file

@ -144,7 +144,7 @@ pub mod iter {
/// false... and so on.
///
/// As we can see, the operator between these two operants is `!(a ^ b)`.
struct ExternalFilterIter(LinkIter, bool);
pub struct ExternalFilterIter(LinkIter, bool);
impl Iterator for ExternalFilterIter {
type Item = Link;
@ -161,6 +161,23 @@ pub mod iter {
}
}
/// Helper trait to be implemented on `LinkIter` to select or deselect all external links
///
/// # See also
///
/// Also see `OnlyExternalIter` and `NoExternalIter` and the helper traits/functions
/// `OnlyInteralLinks`/`only_internal_links()` and `OnlyExternalLinks`/`only_external_links()`.
pub trait SelectExternal {
fn select_external_links(self, b: bool) -> ExternalFilterIter;
}
impl SelectExternal for LinkIter {
fn select_external_links(self, b: bool) -> ExternalFilterIter {
ExternalFilterIter(self, b)
}
}
pub struct OnlyExternalIter(ExternalFilterIter);
impl OnlyExternalIter {