#![warn(missing_docs)]
extern crate ansi_term;
extern crate itertools;
#[cfg(feature = "termion")]
extern crate termion;
#[cfg(test)]
#[macro_use]
extern crate proptest;
#[macro_use]
mod macros;
mod ctors;
mod render;
#[cfg(test)]
mod tests;
use std::borrow::Cow;
pub use ansi_term::{Colour, Style};
pub use render::Display;
#[derive(Clone, Debug, PartialEq)]
pub struct Doc {
inner: DocInner,
}
impl From<DocInner> for Doc {
fn from(inner: DocInner) -> Doc {
Doc { inner }
}
}
#[derive(Clone, Debug, PartialEq)]
enum DocInner {
Alt(Box<DocInner>, Box<DocInner>),
Append(Box<DocInner>, Box<DocInner>),
Line(Option<&'static str>),
Nest(usize, Box<DocInner>),
Style(Style, Box<DocInner>),
Text(Cow<'static, str>),
}
pub trait Sparkly {
fn to_doc(&self) -> Doc;
}
impl Sparkly for Doc {
fn to_doc(&self) -> Doc {
self.clone()
}
}
impl<'a, T: Sparkly> Sparkly for &'a T {
fn to_doc(&self) -> Doc {
(*self).to_doc()
}
}