Skip to content

Commit

Permalink
Implement Debug on all public structs
Browse files Browse the repository at this point in the history
Some types in this crate don't have Debug implemented, but it's annoying
to use a non-Debug type in a struct with Debug derived. I just used the
automatic impl from `#[derive(Debug)]` for all of these (although in the
future it might be good to have custom implementations for types with
complex internals).

Closes #95.
  • Loading branch information
syvb committed Feb 21, 2024
1 parent 184277a commit 1f88570
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/grapheme.rs
Expand Up @@ -19,7 +19,7 @@ use crate::tables::grapheme::GraphemeCat;
///
/// [`grapheme_indices`]: trait.UnicodeSegmentation.html#tymethod.grapheme_indices
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct GraphemeIndices<'a> {
start_offset: usize,
iter: Graphemes<'a>,
Expand Down
12 changes: 6 additions & 6 deletions src/sentence.rs
Expand Up @@ -18,7 +18,7 @@ mod fwd {

// Describe a parsed part of source string as described in this table:
// https://unicode.org/reports/tr29/#Default_Sentence_Boundaries
#[derive(Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum StatePart {
Sot,
Eot,
Expand All @@ -33,7 +33,7 @@ mod fwd {
STerm,
}

#[derive(Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq)]
struct SentenceBreaksState(pub [StatePart; 4]);

const INITIAL_STATE: SentenceBreaksState = SentenceBreaksState([
Expand All @@ -43,7 +43,7 @@ mod fwd {
StatePart::Sot,
]);

#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct SentenceBreaks<'a> {
pub string: &'a str,
pos: usize,
Expand Down Expand Up @@ -296,7 +296,7 @@ mod fwd {
///
/// [`unicode_sentences`]: trait.UnicodeSegmentation.html#tymethod.unicode_sentences
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct UnicodeSentences<'a> {
inner: Filter<USentenceBounds<'a>, fn(&&str) -> bool>,
}
Expand All @@ -309,7 +309,7 @@ pub struct UnicodeSentences<'a> {
///
/// [`split_sentence_bounds`]: trait.UnicodeSegmentation.html#tymethod.split_sentence_bounds
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct USentenceBounds<'a> {
iter: fwd::SentenceBreaks<'a>,
sentence_start: Option<usize>,
Expand All @@ -322,7 +322,7 @@ pub struct USentenceBounds<'a> {
///
/// [`split_sentence_bound_indices`]: trait.UnicodeSegmentation.html#tymethod.split_sentence_bound_indices
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct USentenceBoundIndices<'a> {
start_offset: usize,
iter: USentenceBounds<'a>,
Expand Down
6 changes: 4 additions & 2 deletions src/word.rs
Expand Up @@ -25,6 +25,7 @@ use crate::tables::word::WordCat;
///
/// [`unicode_words`]: trait.UnicodeSegmentation.html#tymethod.unicode_words
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
#[derive(Debug)]
pub struct UnicodeWords<'a> {
inner: Filter<UWordBounds<'a>, fn(&&str) -> bool>,
}
Expand Down Expand Up @@ -62,6 +63,7 @@ impl<'a> DoubleEndedIterator for UnicodeWords<'a> {
///
/// [`unicode_word_indices`]: trait.UnicodeSegmentation.html#tymethod.unicode_word_indices
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
#[derive(Debug)]
pub struct UnicodeWordIndices<'a> {
inner: Filter<UWordBoundIndices<'a>, fn(&(usize, &str)) -> bool>,
}
Expand Down Expand Up @@ -94,7 +96,7 @@ impl<'a> DoubleEndedIterator for UnicodeWordIndices<'a> {
///
/// [`split_word_bounds`]: trait.UnicodeSegmentation.html#tymethod.split_word_bounds
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct UWordBounds<'a> {
string: &'a str,
cat: Option<WordCat>,
Expand All @@ -108,7 +110,7 @@ pub struct UWordBounds<'a> {
///
/// [`split_word_bound_indices`]: trait.UnicodeSegmentation.html#tymethod.split_word_bound_indices
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct UWordBoundIndices<'a> {
start_offset: usize,
iter: UWordBounds<'a>,
Expand Down

0 comments on commit 1f88570

Please sign in to comment.