Skip to content

Commit

Permalink
Remove unnecessary Debug implementations
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
mgeisler committed Sep 14, 2024
1 parent 4a13611 commit 36c4718
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 35 deletions.
12 changes: 1 addition & 11 deletions src/word_separators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::core::Word;
/// let words = AsciiSpace.find_words("Hello World!").collect::<Vec<_>>();
/// 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.
///
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 1 addition & 12 deletions src/word_splitters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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<WordSplitter> for WordSplitter {
fn eq(&self, other: &WordSplitter) -> bool {
Expand Down
13 changes: 1 addition & 12 deletions src/wrap_algorithms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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.
///
Expand Down

0 comments on commit 36c4718

Please sign in to comment.