File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -301,9 +301,10 @@ impl OpType {
301
301
}
302
302
303
303
/// Cast to an extension operation.
304
+ ///
305
+ /// Returns `None` if the operation is not of the requested type.
304
306
pub fn cast < T : MakeExtensionOp > ( & self ) -> Option < T > {
305
- self . as_extension_op ( )
306
- . and_then ( |o| T :: from_extension_op ( o) . ok ( ) )
307
+ self . as_extension_op ( ) . and_then ( ExtensionOp :: cast)
307
308
}
308
309
309
310
/// Returns the extension where the operation is defined, if any.
Original file line number Diff line number Diff line change 12
12
:: proptest_derive:: Arbitrary ,
13
13
} ;
14
14
15
+ use crate :: extension:: simple_op:: MakeExtensionOp ;
15
16
use crate :: extension:: { ConstFoldResult , ExtensionId , OpDef , SignatureError } ;
16
17
use crate :: types:: { type_param:: TypeArg , Signature } ;
17
18
use crate :: { ops, IncomingPort , Node } ;
@@ -123,6 +124,18 @@ impl ExtensionOp {
123
124
pub ( crate ) fn args_mut ( & mut self ) -> & mut [ TypeArg ] {
124
125
self . args . as_mut_slice ( )
125
126
}
127
+
128
+ /// Cast the operation to an specific extension op.
129
+ ///
130
+ /// Returns `None` if the operation is not of the requested type.
131
+ pub fn cast < T : MakeExtensionOp > ( & self ) -> Option < T > {
132
+ T :: from_extension_op ( self ) . ok ( )
133
+ }
134
+
135
+ /// Returns the extension id of the operation.
136
+ pub fn extension_id ( & self ) -> & ExtensionId {
137
+ self . def . extension_id ( )
138
+ }
126
139
}
127
140
128
141
impl From < ExtensionOp > for OpaqueOp {
You can’t perform that action at this time.
0 commit comments