Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding missing size_hint for UnicodeSentences, UnicodeWords, and UnicodeWordIndices #128

Merged
merged 1 commit into from Dec 24, 2023

Conversation

ryanavella
Copy link
Contributor

@ryanavella ryanavella commented Dec 24, 2023

I don't expect this to noticeably impact performance either positively or negatively for most use-cases, especially because Iterator::collect relies on the lower bound of size_hint which will remain unchanged after this PR.

However the upper bound will go from None to Some(upper), which may benefit downstream crates that use it as a heuristic for pre-allocation size.

Note also that I forwarded the implementation of size_hint to the inner iterator, which means it is UAX#29 agnostic. I'm not enough of a Unicode expert to know if e.g. word boundaries can be empty, so it may not be the tightest possible upper bound for longer strings.

@Manishearth Manishearth merged commit 062c264 into unicode-rs:master Dec 24, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants