unicode-rs / unicode-segmentation

Grapheme Cluster and Word boundaries according to UAX#29 rules
https://unicode-rs.github.io/unicode-segmentation
Other
565 stars 57 forks source link

Please add a `Debug` implementation for `Graphemes` and so on #95

Closed ChaiTRex closed 6 months ago

ChaiTRex commented 3 years ago

The std::str::Chars iterator has a nice Debug output:

fn main() {
    let mut chars = "abc".chars();
    println!("{:?}", chars);
    chars.next();
    println!("{:?}", chars);
}

produces:

Chars(['a', 'b', 'c'])
Chars(['b', 'c'])

It would be nice to see unicode_segmentation::Graphemes and so forth implement a nice Debug output to display what they're going to be producing in the future.

timClicks commented 3 years ago

One of the complications with Debug is that, by default, it exposes lots of internals. Graphenes holds a lot of state, and so its Debug output is quite ugly.

I've submitted #98 anyway. Let's see what the maintainers think

Manishearth commented 3 years ago

Yeah, we could improve the debug impl but for now this one is fine