6

Test and fix `size_hint` for slice’s [r]split* iterators by steffahn · Pull Requ...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/87974
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Contributor

steffahn commented 7 days ago

edited

Adds extensive test (of size_hint) for all the [r]split* iterators.
Fixes size_hint upper bound for split_inclusive* iterators which was one higher than necessary for non-empty slices.
Fixes size_hint lower bound for [r]splitn* iterators when n == 0, which was one too high.

Lower bound being one too high was a logic error, violating the correctness condition of size_hint.

Edit: I’ve opened an issue for that bug, so this PR fixes #87978


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK