Skip to content

Add try_count - #7

Merged
extremeandy merged 4 commits into
extremeandy:masterfrom
Iizuki:try_collect
Mar 20, 2026
Merged

Add try_count#7
extremeandy merged 4 commits into
extremeandy:masterfrom
Iizuki:try_collect

Conversation

@Iizuki

Copy link
Copy Markdown
Contributor

Summary

Adding try_count stream terminator.

It counts the elements in a stream of results, or returns early if it finds an error.

Design

I just used the existing TryStream trait 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 plain Stream.

Misc

Added crate categories to Cargo.toml. Might help a little with discoverability.

Also run cargo fmt which made u bunch of small changes here and there.

Issue refs

closes: #6

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_count via a new TryCount future and a StreamTools extension method.
  • Bump crate version to 0.7.7, add crates.io categories, and update CHANGELOG.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
FileDescription
src/try_count.rsNew TryCount future implementing the short-circuiting count logic.
src/lib.rsWires try_count into StreamTools and adds the new module.
src/throttle_last.rsFormatting/import-order and missing semicolon fix.
src/test_util/delay_items.rsImport order formatting.
src/sample.rsFormatting/import-order and semicolon fix.
src/merge_join_by.rsImport order formatting.
src/flatten_switch.rsImport order formatting.
src/fast_forward.rsImport order formatting and semicolon fix.
build.rsImport order formatting.
Cargo.tomlVersion bump to 0.7.7 and add crate categories.
CHANGELOG.mdAdd 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.

Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs
Comment threadsrc/try_count.rs
Comment threadsrc/lib.rs
@extremeandy
extremeandy merged commit 01cba7d into extremeandy:masterMar 20, 2026
3 checks passed
Sign up for freeto 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.

[Feature Request]: try_count

3 participants

@Iizuki@extremeandy