@@ -17,7 +17,7 @@ use core::{
1717use mlir_sys:: {
1818 mlirOperationClone, mlirOperationDestroy, mlirOperationEqual, mlirOperationPrint, MlirOperation ,
1919} ;
20- pub use operation_like:: OperationLike ;
20+ pub use operation_like:: { OperationLike , OperationLikeMut } ;
2121use std:: {
2222 ffi:: c_void,
2323 fmt:: { Debug , Display , Formatter } ,
@@ -73,6 +73,14 @@ impl<'c: 'a, 'a> OperationLike<'c, 'a> for &'a Operation<'c> {
7373 }
7474}
7575
76+ impl < ' c : ' a , ' a > OperationLike < ' c , ' a > for & ' a mut Operation < ' c > {
77+ fn to_raw ( self ) -> MlirOperation {
78+ self . raw
79+ }
80+ }
81+
82+ impl < ' c : ' a , ' a > OperationLikeMut < ' c , ' a > for & ' a mut Operation < ' c > { }
83+
7684impl Clone for Operation < ' _ > {
7785 fn clone ( & self ) -> Self {
7886 unsafe { Self :: from_raw ( mlirOperationClone ( self . raw ) ) }
@@ -198,6 +206,8 @@ impl<'c: 'a, 'a> OperationLike<'c, 'a> for OperationRefMut<'c, 'a> {
198206 }
199207}
200208
209+ impl < ' c : ' a , ' a > OperationLikeMut < ' c , ' a > for OperationRefMut < ' c , ' a > { }
210+
201211impl OperationRefMut < ' _ , ' _ > {
202212 /// Creates an operation reference from a raw object.
203213 ///
@@ -265,8 +275,8 @@ mod tests {
265275 use crate :: {
266276 context:: Context ,
267277 ir:: {
268- attribute:: StringAttribute , Block , BlockLike , Location , OperationLike , Region ,
269- RegionLike , Type ,
278+ attribute:: StringAttribute , Block , BlockLike , Location , OperationLike ,
279+ OperationLikeMut , Region , RegionLike , Type ,
270280 } ,
271281 test:: create_test_context,
272282 Error ,
0 commit comments