Skip to content

Commit

Permalink
feat: Add a FuncTypeBase::io method (#1458)
Browse files Browse the repository at this point in the history
Small helper method, should be enough to close #1209.
  • Loading branch information
aborgna-q authored Aug 21, 2024
1 parent a61f4df commit c7cd840
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hugr-core/src/types/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ impl<RV: MaybeRV> FuncTypeBase<RV> {
&self.output
}

#[inline]
/// Returns a tuple with the input and output rows of the function.
pub fn io(&self) -> (&TypeRowBase<RV>, &TypeRowBase<RV>) {
(&self.input, &self.output)
}

pub(super) fn validate(
&self,
extension_registry: &ExtensionRegistry,
Expand Down Expand Up @@ -310,5 +316,6 @@ mod test {

assert_eq!(f_type.input_types(), &[Type::UNIT]);
assert_eq!(f_type.output_types(), &[USIZE_T]);
assert_eq!(f_type.io(), (&type_row![Type::UNIT], &type_row![USIZE_T]));
}
}

0 comments on commit c7cd840

Please sign in to comment.