Add SelectExternal LinkIter extension trait
This commit is contained in:
parent
647f25a904
commit
4ca501c03e
1 changed files with 18 additions and 1 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue