fluent_ansi/
reset.rs

1use core::fmt::{Display, Formatter, Result};
2
3use crate::{Style, impl_macros::from_to::impl_from_to};
4
5/// A type that represents the reset of all styling.
6///
7/// When rendered, it produces the ANSI escape sequence to reset all styling.
8///
9/// It is equal to a [`Style::new()`].
10///
11/// See [The `Reset` singleton](crate#the-reset-singleton).
12#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
13pub struct Reset;
14
15impl_from_to!(
16    #[doc = r"Converts the type into a [`Style`]."]
17    fn to_style(self: Reset) -> Style {
18        Style::new()
19    }
20);
21
22impl Display for Reset {
23    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
24        write!(f, "{}", Style::new())
25    }
26}
27
28impl PartialEq<Style> for Reset {
29    fn eq(&self, other: &Style) -> bool {
30        self.to_style() == *other
31    }
32}