-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: Add Type::as_sum
and SumType::variants
.
#1914
Conversation
I've taken the liberty of fixing some unrelated compile warnings. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1914 +/- ##
==========================================
+ Coverage 83.77% 83.78% +0.01%
==========================================
Files 196 196
Lines 37374 37404 +30
Branches 34187 34217 +30
==========================================
+ Hits 31311 31340 +29
- Misses 4285 4286 +1
Partials 1778 1778
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
/// Returns an iterator over the variants. | ||
pub fn variants(&self) -> impl Iterator<Item = &TypeRowRV> { | ||
match self { | ||
SumType::Unit { size } => Either::Left(itertools::repeat_n( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand the use of Either here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to return a single type which impls Iterator. The two branches of the match create different types, so to unify those into a single return return type we use Either
. We exploit this impl: https://docs.rs/itertools/latest/itertools/enum.Either.html#impl-Iterator-for-Either%3CL,+R%3E
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
## 🤖 New release * `hugr`: 0.14.3 -> 0.14.4 (✓ API compatible changes) * `hugr-core`: 0.14.3 -> 0.14.4 (✓ API compatible changes) * `hugr-llvm`: 0.14.3 -> 0.14.4 (✓ API compatible changes) * `hugr-passes`: 0.14.3 -> 0.14.4 * `hugr-cli`: 0.14.3 -> 0.14.4 <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr` <blockquote> ## [0.14.4](hugr-v0.14.3...hugr-v0.14.4) - 2025-02-24 ### Bug Fixes - delegate default impls in HugrView (#1921) ### New Features - add xor to logic extension (#1911) - Add `Type::as_sum` and `SumType::variants`. (#1914) - Add `HugrMutInternals::insert_ports` (#1915) </blockquote> ## `hugr-core` <blockquote> ## [0.14.4](hugr-core-v0.14.3...hugr-core-v0.14.4) - 2025-02-24 ### Bug Fixes - delegate default impls in HugrView (#1921) ### New Features - add xor to logic extension (#1911) - Add `Type::as_sum` and `SumType::variants`. (#1914) - Add `HugrMutInternals::insert_ports` (#1915) </blockquote> ## `hugr-llvm` <blockquote> ## [0.14.4](hugr-llvm-v0.14.3...hugr-llvm-v0.14.4) - 2025-02-24 ### New Features - add xor to logic extension (#1911) - *(hugr-llvm)* Add extension points to `PreludeCodegen` for customising string lowering (#1918) </blockquote> ## `hugr-passes` <blockquote> ## [0.14.3](hugr-passes-v0.14.2...hugr-passes-v0.14.3) - 2025-02-05 ### Bug Fixes - Export `RemoveDeadFuncsError` (#1883) - const-folding Module keeps at least "main" (#1901) ### Documentation - Fix deprecation warning messages (#1891) </blockquote> ## `hugr-cli` <blockquote> ## [0.14.1](hugr-cli-v0.14.0...hugr-cli-v0.14.1) - 2024-12-18 ### New Features - Print `hugr-cli`'s correct version when using '--version' (#1790) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/).
No description provided.