Skip to content

More ergonomic which#640

Open
stepancheg wants to merge 1 commit intocapnproto:masterfrom
stepancheg:which
Open

More ergonomic which#640
stepancheg wants to merge 1 commit intocapnproto:masterfrom
stepancheg:which

Conversation

@stepancheg
Copy link
Copy Markdown
Contributor

@stepancheg stepancheg commented Mar 30, 2026

In which() return Result<Which<Reader>, Error> instead of Result<Which<Result<Reader, Error>>, NotInSchema>.

Extracting NotInSchema is tricker now, because it is now a variant of Error. Also it is not possible now have more detailed errors which variant is broken.

I think it's OK, because:

  • in majority of cases people don't handle of every error in every enum
  • being able to do exhaustive matching ergonomically is important, e.g.
match which? {
  Which::File(file) => { ... }
  Which::Directory(file) => { ... }
}

instead of

match which? {
  Which::File(Ok(file)) => { ... }
  Which::Directory(Ok(file)) => { ... }
  Which::File(Err(e)) | Which::Directory(Err(e)) => return Err(e),
}

@stepancheg stepancheg force-pushed the which branch 3 times, most recently from d28cee1 to 11bb83b Compare March 30, 2026 00:43
@stepancheg stepancheg marked this pull request as draft March 30, 2026 01:17
@stepancheg stepancheg force-pushed the which branch 3 times, most recently from 07c596b to a7c50c3 Compare March 30, 2026 02:01
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 23.28042% with 145 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.02%. Comparing base (ab342b3) to head (8e5d5a7).
⚠️ Report is 280 commits behind head on master.

Files with missing lines Patch % Lines
capnp-rpc/src/rpc_capnp.rs 14.28% 60 Missing ⚠️
capnp/src/schema_capnp.rs 6.81% 41 Missing ⚠️
capnpc/src/codegen.rs 6.66% 28 Missing ⚠️
capnp-rpc/src/rpc.rs 61.76% 13 Missing ⚠️
capnpc/src/codegen_types.rs 0.00% 2 Missing ⚠️
capnp/src/dynamic_value.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #640      +/-   ##
==========================================
- Coverage   51.64%   51.02%   -0.62%     
==========================================
  Files          69       71       +2     
  Lines       33735    32406    -1329     
==========================================
- Hits        17422    16536     -886     
+ Misses      16313    15870     -443     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stepancheg stepancheg marked this pull request as ready for review March 30, 2026 02:41
@dwrensha dwrensha added the breaking change requires version bump label Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change requires version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants