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
    }
}
