use core::fmt::{Display, Formatter, Result};
use crate::{Style, ToStyle};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct Reset;
impl Display for Reset {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "{}", Style::new())
}
}
impl PartialEq<Style> for Reset {
fn eq(&self, other: &Style) -> bool {
self.to_style() == *other
}
}
impl ToStyle for Reset {
fn to_style(self) -> Style {
self.into()
}
}
#[cfg(test)]
mod tests {
use crate::{ToStyleSet as _, assert_display};
use super::*;
#[test]
fn reset() {
assert_display!(Reset, "\x1b[0m");
}
#[test]
fn eq() {
assert_eq!(Reset, Reset);
assert_eq!(Reset, Style::new());
assert_ne!(Reset, Style::new().bold());
assert_eq!(Style::new(), Reset);
assert_ne!(Style::new().bold(), Reset);
}
#[test]
fn to_style() {
assert_eq!(Reset.to_style(), Style::new());
}
}