| 1 | /// Reset terminal formatting |
| 2 | #[allow(clippy::exhaustive_structs)] |
| 3 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 4 | pub struct Resetrust-analyzer cargo anstyle 1.0.14 reset/Reset#; |
| 5 | |
| 6 | impl Resetrust-analyzer cargo anstyle 1.0.14 reset/Reset# { |
| 7 | /// Render the ANSI code |
| 8 | /// |
| 9 | /// `Reset` also implements `Display` directly, so calling this method is optional. |
| 10 | #[inline] |
| 11 | pub fn renderrust-analyzer cargo anstyle 1.0.14 reset/impl#[Reset]render().(self) -> impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# { |
| 12 | self |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Resetrust-analyzer cargo anstyle 1.0.14 reset/Reset# { |
| 17 | fn fmtrust-analyzer cargo anstyle 1.0.14 reset/impl#[Reset][Display]fmt().(&self, f: &mut corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 18 | f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(RESETrust-analyzer cargo anstyle 1.0.14 reset/RESET.) |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | pub(craterust-analyzer cargo anstyle 1.0.14 crate/) const RESETrust-analyzer cargo anstyle 1.0.14 reset/RESET.: &str = "\x1B[0m"; |
| 23 | |
| 24 | #[cfg(test)] |
| 25 | #[cfg(feature = "std")] |
| 26 | mod testrust-analyzer cargo anstyle 1.0.14 reset/test/ { |
| 27 | use superrust-analyzer cargo anstyle 1.0.14 reset/::*; |
| 28 | |
| 29 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 30 | fn print_size_ofrust-analyzer cargo anstyle 1.0.14 reset/test/print_size_of().() { |
| 31 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().; |
| 32 | dbgrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/dbg!!(size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<Resetrust-analyzer cargo anstyle 1.0.14 reset/Reset#>()); |
| 33 | } |
| 34 | |
| 35 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 36 | fn no_alignrust-analyzer cargo anstyle 1.0.14 reset/test/no_align().() { |
| 37 | #[track_caller] |
| 38 | fn assert_no_alignrust-analyzer cargo anstyle 1.0.14 reset/test/assert_no_align().(d: impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#) { |
| 39 | let expected = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{d}"); |
| 40 | let actual = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{d:<10}"); |
| 41 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, actual); |
| 42 | } |
| 43 | |
| 44 | assert_no_alignrust-analyzer cargo anstyle 1.0.14 reset/test/assert_no_align().(Resetrust-analyzer cargo anstyle 1.0.14 reset/Reset#); |
| 45 | assert_no_alignrust-analyzer cargo anstyle 1.0.14 reset/test/assert_no_align().(Resetrust-analyzer cargo anstyle 1.0.14 reset/Reset#.renderrust-analyzer cargo anstyle 1.0.14 reset/impl#[Reset]render().()); |
| 46 | } |
| 47 | } |