1#[cfg_attr(feature = "std", doc = "and [`ANSIBuf`].")]
3#[cfg(feature = "std")]
4mod ansi_buf;
5mod ansi_str;
6
7#[cfg(feature = "std")]
8pub use ansi_buf::ANSIBuf;
9
10pub use self::ansi_str::ANSIStr;
11
12use core::fmt::{self, Write};
13
14pub trait ANSIFmt {
16 fn fmt_ansi_prefix<W: Write>(&self, f: &mut W) -> fmt::Result;
18
19 fn fmt_ansi_suffix<W: Write>(&self, f: &mut W) -> fmt::Result {
21 f.write_str("\u{1b}[0m")
22 }
23}
24
25impl<C> ANSIFmt for &C
26where
27 C: ANSIFmt,
28{
29 fn fmt_ansi_prefix<W: Write>(&self, f: &mut W) -> fmt::Result {
30 C::fmt_ansi_prefix(self, f)
31 }
32
33 fn fmt_ansi_suffix<W: Write>(&self, f: &mut W) -> fmt::Result {
34 C::fmt_ansi_suffix(self, f)
35 }
36}