1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
use std::fmt::Formatter;

use crate::Style;

use crate::{EmitBackendTrait, EmitResult};

pub struct EmitForTest;

impl EmitBackendTrait for EmitForTest {
    fn emit(&self, f: &mut Formatter<'_>, fragment: &str, style: &Style) -> EmitResult {
        if fragment == "\n" {
            writeln!(f)?;
        } else {
            write!(f, "[{:?}:{}]", style, fragment)?;
        }

        Ok(())
    }
}