diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-10-15 15:20:36 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-10-19 13:03:17 +0200 |
commit | 4ca501c03efb91aac52a8ed53e5e8f9f2241b562 (patch) | |
tree | 6da5ef87c2c97ede495ecbfbcd8d95959b15d552 /libimagentrylink | |
parent | 647f25a9049052591a1193ff77796ac8238eb1fe (diff) |
Add SelectExternal LinkIter extension trait
Diffstat (limited to 'libimagentrylink')
-rw-r--r-- | libimagentrylink/src/external.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libimagentrylink/src/external.rs b/libimagentrylink/src/external.rs index 88985e88..85edf8a9 100644 --- a/libimagentrylink/src/external.rs +++ b/libimagentrylink/src/external.rs @@ -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 { |