Skip to content
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: Support copies in pattern matching #127

Merged
merged 2 commits into from
Sep 21, 2023
Merged

Conversation

lmondada
Copy link
Contributor

@lmondada lmondada commented Sep 21, 2023

  • feat: Support copies in pattern matching

@lmondada lmondada requested a review from aborgna-q September 21, 2023 15:27
) -> Result<Self, InvalidEdgeProperty> {
let src = port;
let (dst_node, dst) = circ.linked_ports(node, src).exactly_one().map_err(|e| {
if e.size_hint().0 > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

check if you can use peek instead

let PEdge::InternalEdge { dst: dst1, .. } = e1 else {
return false;
};
let src2 = match *e2 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you use offset_id ?

let (next_node, next_port) = circ.linked_ports(src, src_port).exactly_one().ok()?;
(dst_port == next_port).then_some(NodeID::HugrNode(next_node))
}
PEdge::InputEdge { src: src_port } => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doc the invariant if you want

Comment on lines 104 to 110
let NodeID::HugrNode(node_p) = node_p else {
return None;
};
let NodeID::HugrNode(node_c) = node_c else {
return None;
};
Some((node_p, node_c))
Copy link
Collaborator

Choose a reason for hiding this comment

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

just match

@lmondada lmondada merged commit f7e9237 into main Sep 21, 2023
@lmondada lmondada deleted the feat/portmatching-copy branch September 21, 2023 16:11
ss2165 pushed a commit that referenced this pull request Sep 25, 2023
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

Successfully merging this pull request may close these issues.

2 participants