1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
//!
//! Clear line helper (ANSI escape codes to clear the terminal line)
//!
use std::fmt;
pub struct ClearLine;
impl fmt::Display for ClearLine {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "\x1B[2K\r")
}
}
impl AsRef<[u8]> for ClearLine {
fn as_ref(&self) -> &'static [u8] {
"\x1B[2K\r".as_bytes()
}
}
impl AsRef<str> for ClearLine {
fn as_ref(&self) -> &'static str {
"\x1B[2K\r"
}
}