Skip to content

Commit

Permalink
feat: Make various data publicly accessible (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-q authored Mar 14, 2024
1 parent db1d11c commit 6ff6c01
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
15 changes: 15 additions & 0 deletions quantinuum-hugr/src/ops/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ impl TypeApplication {
})
}
}

/// Returns the type of the input function.
pub fn input(&self) -> &PolyFuncType {
&self.input
}

/// Returns the args applied to the input function.
pub fn args(&self) -> &[TypeArg] {
&self.args
}

/// Returns the type of the output function.
pub fn output(&self) -> &PolyFuncType {
&self.output
}
}

impl Default for LeafOp {
Expand Down
12 changes: 12 additions & 0 deletions quantinuum-hugr/src/types/type_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ impl UpperBound {
_ => false,
}
}

/// Returns the value of the upper bound.
pub fn value(&self) -> &Option<NonZeroU64> {
&self.0
}
}

/// A *kind* of [TypeArg]. Thus, a parameter declared by a [PolyFuncType] (e.g. [OpDef]),
Expand Down Expand Up @@ -246,6 +251,13 @@ impl TypeArg {
}
}

impl TypeArgVariable {
/// Return the index.
pub fn index(&self) -> usize {
self.idx
}
}

/// A serialized representation of a value of a [CustomType]
/// restricted to equatable types.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
Expand Down
5 changes: 5 additions & 0 deletions quantinuum-hugr/src/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ impl CustomSerialized {
extensions,
}
}

/// Returns the inner value.
pub fn value(&self) -> &serde_yaml::Value {
&self.value
}
}

#[typetag::serde]
Expand Down

0 comments on commit 6ff6c01

Please sign in to comment.