dahosek / finl_unicode

Unicode support for the finl project
Apache License 2.0
16 stars 7 forks source link

Implement `PeekChar` for `Iterator<Item=char>` #12

Closed spencerwhite closed 2 years ago

spencerwhite commented 2 years ago

I made a very small change that allows any Iterator over chars to use the next_cluster() function from GraphemeCluster. Admittedly, it got a little ugly in order to keep CharIndices implemented. I hope this would be a welcome addition since it makes the code much more generic, though admittedly more messy. Will submit a PR soon.

dahosek commented 2 years ago

Just to let you know that I have your PR on my to-do list for review.

dahosek commented 2 years ago

Do you have an example of Iterator<Item=char> that’s not Chars?

dahosek commented 2 years ago

Changes vetted and merged

spencerwhite commented 2 years ago

Do you have an example of Iterator<Item=char> that’s not Chars?

Hey, I'm sorry I totally forgot to respond to this. School and all. Anyway, the idea was that I wanted to be able to find the nth grapheme cluster in a string without having to read the whole string. Then you could use it with async Streams and such