summaryrefslogtreecommitdiffstats
path: root/libimagentrymarkdown
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-05-29 17:08:27 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-06-09 16:52:34 +0200
commitdb93f01ea38999d1afa5d053837266d3b5e75500 (patch)
treea9c67e92b3e5cd8e77fa8f9794165d419a137cbc /libimagentrymarkdown
parent12369ddadf0d0d4fa1618f8fdde6866a3a10c203 (diff)
Add WithHtmlIterator to iterate over (Entry, Result<HTML>) tuples
Diffstat (limited to 'libimagentrymarkdown')
-rw-r--r--libimagentrymarkdown/src/html.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/libimagentrymarkdown/src/html.rs b/libimagentrymarkdown/src/html.rs
index 09038751..f9d251a8 100644
--- a/libimagentrymarkdown/src/html.rs
+++ b/libimagentrymarkdown/src/html.rs
@@ -53,4 +53,30 @@ pub mod iter {
}
+
+ /// Iterate over `(Entry, Result<HTML>)` tuples
+ pub struct WithHtmlIterator<I: Iterator<Item = Entry>> {
+ i: I
+ }
+
+ impl<I: Iterator<Item = Entry>> WithHtmlIterator<I> {
+
+ fn new(i: I) -> WithHtmlIterator<I> {
+ WithHtmlIterator { i: i }
+ }
+
+ }
+
+ impl<I: Iterator<Item = Entry>> Iterator for WithHtmlIterator<I> {
+ type Item = (Entry, Result<HTML>);
+
+ fn next(&mut self) -> Option<Self::Item> {
+ self.i.next().map(|entry| {
+ let html = to_html(&entry.get_content()[..]);
+ (entry, html)
+ })
+ }
+
+ }
+
}