Skip to content

Conversion SimpleReplacement -> Replacement #2062

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

Open
lmondada opened this issue Apr 7, 2025 · 0 comments
Open

Conversion SimpleReplacement -> Replacement #2062

lmondada opened this issue Apr 7, 2025 · 0 comments

Comments

@lmondada
Copy link
Contributor

lmondada commented Apr 7, 2025

Implement

impl From<Replacement> for SimpleReplacement

or a similar dedicated trait to convert a SimpleReplacement to Replacement. This could also be a method on SimpleReplacement, but that would make it impossible to provide blanket implementations of Rewrite<PersistentHugr>.

This is required to be able to add SimpleReplacements to PersistentHugrs, which will (presumably) be made of Replacements.

Note that there is an argument for not implementing From, but rather a custom trait: one could imagine a rewrite struct InlineCall that only stores the Node ID of a call op, but can be turned into a Replacement if it is given a reference to the underlying Hugr: it needs to clone the body of the function to be inlined into the replacement graph. Such a conversion would have the signature fn into_replacement(self, hugr: &impl HugrView) -> Replacement

@lmondada lmondada transferred this issue from CQCL/tket2 Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant