quatrain 0.6.0

Not intended to be a static site generator
Documentation
use auto_enums::auto_enum;
use crate::{Event, FrontMatter, ReadableDate, Tag};
use std::cell::Ref;
use std::iter::{empty, once};

pub fn predict<'e>(e: &Event<'e>) -> bool {
    match &e {
        Event::End(Tag::Heading(1)) => true,
        _ => false,
    }
}

#[auto_enum(Iterator)]
pub fn event<'e>(fm: Ref<Option<FrontMatter>>) -> impl Iterator<Item = Event<'e>> {
    match fm
        .as_ref()
        .and_then(|fm| fm.last_update.as_ref())
        .and_then(|lst| Some((&ReadableDate::today() - lst).num_days()))
    {
        Some(count) => {
            let duration = fm.as_ref().unwrap().banner.outdate;
            #[nested]
            match count > duration && duration != 0 {
                true => once(Event::Html(
                    format!(
                        r#"<div class="banner outdate-banner">Content might be outdated. Last modified {} days ago.</div>"#,
                        count
                    )
                    .into(),
                )),
                _ => empty(),
            }
        },
        _ => empty(),
    }
}