-
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!: Split Rewrite trait into VerifyPatch and ApplyPatch #2070
base: main
Are you sure you want to change the base?
Conversation
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.
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2070 +/- ##
==========================================
- Coverage 82.91% 82.89% -0.02%
==========================================
Files 217 217
Lines 41529 41613 +84
Branches 37707 37791 +84
==========================================
+ Hits 34433 34497 +64
- Misses 5292 5311 +19
- Partials 1804 1805 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR contains breaking changes to the public Rust API. cargo-semver-checks summary
|
/// A patch that can be applied to a Hugr of type `H`. | ||
/// | ||
/// ### When to use | ||
/// | ||
/// Use this trait whenever possible in bounds for the most generality. Note | ||
/// that this will require specifying which types `H` the patch applies to. | ||
/// | ||
/// ### When to implement | ||
/// | ||
/// For `H: HugrMut`, prefer implementing [`ApplyPatchHugrMut`] instead. This | ||
/// will automatically implement this trait. | ||
pub trait ApplyPatch<H: HugrView>: VerifyPatch<Node = H::Node> { |
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.
Naming suggestion: Since this is the main entrypoint, could it just be called Patch
?
VerifyPatch
is more niche, and the name still reflects its a verification for the things you'll do on this trait.
This PR splits the
Rewrite
trait into two (three) traits:VerifyPatch
trait that has thefn verify
andfn invalidation_set
functionsApplyPatch
trait that has thefn apply
function. This inheritsVerifyPatch
and is the "rewriting" trait that should be used in most scenarios.In addition, there is a third trait
ApplyPatchHugrMut
that can be implemented by any patches that can be applied to anyHugrMut
(as opposed to a specific typeH
). This is strictly stronger thanApplyPatch
and should be implemented instead ofApplyPatch
where possible (see the docs of the traits).closes #588
closes #2052
BREAKING CHANGE: the
Rewrite
trait was replaced byApplyPatch
. Thehugr/rewrite
module is now calledhugr/patch