1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::{MarkdownExt, Share, FrontMatter};
use std::marker::PhantomData;
use std::rc::Rc;
use std::cell::RefCell;

/// Contains nothing, like [`Empty`], and the FrontMatter data is `None`, ⊥.
///
/// [`Empty`]: https://doc.rust-lang.org/std/iter/struct.Empty.html
#[derive(Debug)]
pub struct Bottom<T>(PhantomData<T>, Share<RefCell<Option<FrontMatter>>>);

impl<T> Bottom<T> {

    /// Create a new `Bottom` struct.
    pub fn new() -> Bottom<T> {
        Bottom (PhantomData, Rc::new(RefCell::new(None)).into())
    }
}

impl<T> Iterator for Bottom<T> {
    type Item = T;

    fn next(&mut self) -> Option<T> {
        None
    }
}

impl<T> MarkdownExt<T> for Bottom<T> {
    fn frontmatter(&mut self) -> &mut Share<RefCell<Option<FrontMatter>>> {
        &mut self.1
    }
}