Skip to content

Commit 8cd3ee9

Browse files
authored
feat: CustomOp::extension utility function (#951)
Small utility function, both variants of a `CustomOp` expose their extension already.
1 parent b7df2ef commit 8cd3ee9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

hugr/src/ops/custom.rs

+8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ impl CustomOp {
6666
}
6767
}
6868

69+
/// Returns the extension ID of this operation.
70+
pub fn extension(&self) -> &ExtensionId {
71+
match self {
72+
Self::Opaque(op) => op.extension(),
73+
Self::Extension(op) => op.def.extension(),
74+
}
75+
}
76+
6977
/// If the operation is an instance of [ExtensionOp], return a reference to it.
7078
/// If the operation is opaque, return None.
7179
pub fn as_extension_op(&self) -> Option<&ExtensionOp> {

0 commit comments

Comments
 (0)