batch_run 1.2.0

Batch runner for arbitrary Rust files within current project
Documentation
use crate::result::PrintError;

use lazy_static::lazy_static;
use termcolor::{
    Buffer,
    BufferWriter,
    ColorChoice,
};

lazy_static! {
    static ref WRITER: BufferWriter = BufferWriter::stdout(ColorChoice::Auto);
}

pub(crate) fn buf() -> Buffer {
    WRITER.buffer()
}

pub(crate) fn print(buf: Option<Buffer>) -> Result<(), PrintError> {
    buf.ok_or(PrintError::AlreadyPrinted)
        .and_then(|buf| WRITER.print(&buf).map_err(PrintError::Io))
}