From 36c47186b157491ae39d81ff519b10e8ff167315 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Sat, 14 Sep 2024 21:40:07 +0200 Subject: [PATCH] Remove unnecessary Debug implementations The `Custom` variants will now print something like `Custom(0x5621e28be920)`, which is actually much better than the `Custom(...)` I came up with. Found with `cargo mutants`. --- src/word_separators.rs | 12 +----------- src/word_splitters.rs | 13 +------------ src/wrap_algorithms.rs | 13 +------------ 3 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/word_separators.rs b/src/word_separators.rs index e06e9b8..09153b1 100644 --- a/src/word_separators.rs +++ b/src/word_separators.rs @@ -38,7 +38,7 @@ use crate::core::Word; /// let words = AsciiSpace.find_words("Hello World!").collect::>(); /// assert_eq!(words, vec![Word::from("Hello "), Word::from("World!")]); /// ``` -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy)] pub enum WordSeparator { /// Find words by splitting on runs of `' '` characters. /// @@ -156,16 +156,6 @@ impl PartialEq for WordSeparator { } } -impl std::fmt::Debug for WordSeparator { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - WordSeparator::AsciiSpace => f.write_str("AsciiSpace"), - #[cfg(feature = "unicode-linebreak")] - WordSeparator::UnicodeBreakProperties => f.write_str("UnicodeBreakProperties"), - WordSeparator::Custom(_) => f.write_str("Custom(...)"), - } - } -} impl WordSeparator { /// Create a new word separator. diff --git a/src/word_splitters.rs b/src/word_splitters.rs index e2dc6aa..a79b53f 100644 --- a/src/word_splitters.rs +++ b/src/word_splitters.rs @@ -33,7 +33,7 @@ use crate::core::{display_width, Word}; /// details. /// /// [hyphenation]: https://docs.rs/hyphenation/ -#[derive(Clone)] +#[derive(Debug, Clone)] pub enum WordSplitter { /// Use this as a [`Options.word_splitter`] to avoid any kind of /// hyphenation: @@ -98,17 +98,6 @@ pub enum WordSplitter { Hyphenation(hyphenation::Standard), } -impl std::fmt::Debug for WordSplitter { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - WordSplitter::NoHyphenation => f.write_str("NoHyphenation"), - WordSplitter::HyphenSplitter => f.write_str("HyphenSplitter"), - WordSplitter::Custom(_) => f.write_str("Custom(...)"), - #[cfg(feature = "hyphenation")] - WordSplitter::Hyphenation(dict) => write!(f, "Hyphenation({})", dict.language()), - } - } -} impl PartialEq for WordSplitter { fn eq(&self, other: &WordSplitter) -> bool { diff --git a/src/wrap_algorithms.rs b/src/wrap_algorithms.rs index 7737e08..1c53809 100644 --- a/src/wrap_algorithms.rs +++ b/src/wrap_algorithms.rs @@ -32,7 +32,7 @@ use crate::core::{Fragment, Word}; /// enabled, a more complex algorithm is available which will look at /// an entire paragraph at a time in order to find optimal line breaks /// ([`WrapAlgorithm::OptimalFit`]). -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub enum WrapAlgorithm { /// Wrap words using a fast and simple algorithm. /// @@ -119,17 +119,6 @@ impl PartialEq for WrapAlgorithm { } } -impl std::fmt::Debug for WrapAlgorithm { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - WrapAlgorithm::FirstFit => f.write_str("FirstFit"), - #[cfg(feature = "smawk")] - WrapAlgorithm::OptimalFit(penalties) => write!(f, "OptimalFit({:?})", penalties), - WrapAlgorithm::Custom(_) => f.write_str("Custom(...)"), - } - } -} - impl WrapAlgorithm { /// Create new wrap algorithm. ///