@@ -100,7 +100,8 @@ pub enum ResultOpDef {
100
100
}
101
101
102
102
impl ResultOpDef {
103
- fn arg_type ( & self ) -> Type {
103
+ /// Type of the argument to the result operation.
104
+ pub fn arg_type ( & self ) -> Type {
104
105
match self {
105
106
Self :: Bool => BOOL_T ,
106
107
Self :: Int | Self :: UInt => int_tv ( 1 ) ,
@@ -133,7 +134,8 @@ impl ResultOpDef {
133
134
}
134
135
}
135
136
136
- fn type_params ( & self ) -> Vec < TypeParam > {
137
+ /// Type parameters for result operation.
138
+ pub fn type_params ( & self ) -> Vec < TypeParam > {
137
139
match self {
138
140
Self :: Bool | Self :: F64 => vec ! [ ] ,
139
141
Self :: Int | Self :: UInt => vec ! [ LOG_WIDTH_TYPE_PARAM ] ,
@@ -145,7 +147,8 @@ impl ResultOpDef {
145
147
}
146
148
}
147
149
148
- fn instantiate ( & self , args : & [ TypeArg ] ) -> Result < ResultOp , OpLoadError > {
150
+ /// Instantiate the result operation with the given type arguments.
151
+ pub fn instantiate ( & self , args : & [ TypeArg ] ) -> Result < ResultOp , OpLoadError > {
149
152
let parsed_args = concrete_result_op_type_args ( args) ?;
150
153
151
154
match ( parsed_args, self ) {
@@ -214,23 +217,32 @@ impl MakeOpDef for ResultOpDef {
214
217
}
215
218
216
219
#[ derive( Clone , Debug , serde:: Serialize , serde:: Deserialize , Hash , PartialEq ) ]
217
- enum SimpleArgs {
220
+ /// Type arguments to a numeric result operation (not an array).
221
+ pub enum SimpleArgs {
222
+ /// No type arguments, simple result type.
218
223
Basic ,
224
+ /// Integer type argument, specifying bit width.
219
225
Int ( u8 ) ,
220
226
}
221
227
222
228
#[ derive( Clone , Debug , serde:: Serialize , serde:: Deserialize , Hash , PartialEq ) ]
223
- enum ResultArgs {
229
+ /// Arguments to a "tket2.result" operation.
230
+ pub enum ResultArgs {
231
+ /// Simple result type, not an array.
224
232
Simple ( SimpleArgs ) ,
233
+ /// Argument for array result type, with inner type arguments and array size.
225
234
Array ( SimpleArgs , u64 ) ,
226
235
}
227
236
228
237
#[ derive( Clone , Debug , serde:: Serialize , serde:: Deserialize , Hash , PartialEq ) ]
229
238
/// Concrete instantiation of a "tket2.result" operation.
230
239
pub struct ResultOp {
231
- tag : String ,
232
- result_op : ResultOpDef ,
233
- args : ResultArgs ,
240
+ /// Static string tag for the result.
241
+ pub tag : String ,
242
+ /// The result operation definition.
243
+ pub result_op : ResultOpDef ,
244
+ /// Type arguments for the result operation.
245
+ pub args : ResultArgs ,
234
246
}
235
247
236
248
impl ResultOp {
0 commit comments