Add try_count - #7
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new StreamTools::try_count() terminator to count Ok items in a TryStream while short-circuiting on the first Err, alongside a version bump + changelog entry and some cargo fmt import/semicolon cleanups.
Changes:
- Introduce
try_countvia a newTryCountfuture and aStreamToolsextension method. - Bump crate version to
0.7.7, add crates.io categories, and updateCHANGELOG.md. - Apply formatting/import-order adjustments across several modules.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/try_count.rs | New TryCount future implementing the short-circuiting count logic. |
| src/lib.rs | Wires try_count into StreamTools and adds the new module. |
| src/throttle_last.rs | Formatting/import-order and missing semicolon fix. |
| src/test_util/delay_items.rs | Import order formatting. |
| src/sample.rs | Formatting/import-order and semicolon fix. |
| src/merge_join_by.rs | Import order formatting. |
| src/flatten_switch.rs | Import order formatting. |
| src/fast_forward.rs | Import order formatting and semicolon fix. |
| build.rs | Import order formatting. |
| Cargo.toml | Version bump to 0.7.7 and add crate categories. |
| CHANGELOG.md | Add 0.7.7 entry noting try_count. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Adding
try_countstream terminator.It counts the elements in a stream of results, or returns early if it finds an error.
Design
I just used the existing
TryStreamtrait as the bound as it's nice and concise. I'm not aware of any downsides compared to specifying the bound more verbosely in terms of plainStream.Misc
Added crate categories to
Cargo.toml. Might help a little with discoverability.Also run
cargo fmtwhich made u bunch of small changes here and there.Issue refs
closes: #6