-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
lmondada
commented
Sep 21, 2023
•
edited
Loading
edited
- feat: Support copies in pattern matching
src/portmatching.rs
Outdated
) -> 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 { |
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.
check if you can use peek instead
src/portmatching/matcher.rs
Outdated
let PEdge::InternalEdge { dst: dst1, .. } = e1 else { | ||
return false; | ||
}; | ||
let src2 = match *e2 { |
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.
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 } => { |
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.
Doc the invariant if you want
src/portmatching/pattern.rs
Outdated
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)) |
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.
just match