etch 0.4.2

Not just a text formatter, don't mark it down, etch it.
Documentation
use crate::nodes::{NodeAttributes, Nodes};
use crate::plugins::Plugins;
use std::cell::RefCell;
use std::rc::Rc;
use std::collections::HashMap;
use std::fmt::Debug;
use std::path::PathBuf;

pub type Shared<T> = Rc<RefCell<T>>;
pub type SharedState = Shared<State>;

#[derive(Clone, Debug)]
pub struct State {
    pub nodes: Nodes,
    pub paths: Vec<PathBuf>,
    pub plugins: Plugins,
    pub tags: HashMap<String, NodeAttributes>,
}

impl Default for State {
    fn default() -> Self {
        State {
            nodes: Nodes::new(),
            paths: vec![std::env::current_dir().unwrap()],
            plugins: Plugins::new(),
            tags: HashMap::new(),
        }
    }
}

impl State {
    pub fn shareable() -> SharedState {
        Shared::share(State::default())
    }

    pub fn current_path(&self) -> PathBuf {
        self.paths.last().unwrap().into()
    }
}

pub trait SharedContructor<T> {
    fn share(item: T) -> Shared<T>;
}

impl<T> SharedContructor<T> for Rc<RefCell<T>> {
    fn share(item: T) -> Shared<T> {
        Rc::new(RefCell::new(item))
    }
}