equt_md_ext/
bottom.rs

1use crate::{MarkdownExt, Share};
2use equt_md_frontmatter::FrontMatter;
3use std::marker::PhantomData;
4use std::rc::Rc;
5use std::cell::RefCell;
6
7/// Contains nothing, like [`Empty`], and the FrontMatter data is `None`, ⊥.
8///
9/// [`Empty`]: https://doc.rust-lang.org/std/iter/struct.Empty.html
10#[derive(Debug)]
11pub struct Bottom<T>(PhantomData<T>, Share<RefCell<Option<FrontMatter>>>);
12
13impl<T> Bottom<T> {
14
15    /// Create a new `Bottom` struct.
16    pub fn new() -> Bottom<T> {
17        Bottom (PhantomData, Rc::new(RefCell::new(None)).into())
18    }
19}
20
21impl<T> Iterator for Bottom<T> {
22    type Item = T;
23
24    fn next(&mut self) -> Option<T> {
25        None
26    }
27}
28
29impl<T> MarkdownExt<T> for Bottom<T> {
30    fn frontmatter(&mut self) -> &mut Share<RefCell<Option<FrontMatter>>> {
31        &mut self.1
32    }
33}