From a244f5f1eb211f56e5cb16bdda956054c7fe00e3 Mon Sep 17 00:00:00 2001 From: Agustin Borgna Date: Mon, 3 Jul 2023 16:13:02 +0100 Subject: [PATCH] feat: return a slice of types from the signature --- src/types.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/types.rs b/src/types.rs index 9fc442a9c..4b68aa323 100644 --- a/src/types.rs +++ b/src/types.rs @@ -208,6 +208,27 @@ impl Signature { pub fn output_ports(&self) -> impl Iterator { self.ports(Direction::Outgoing) } + + /// Returns a slice of the value types for the given direction. + #[inline] + pub fn df_types(&self, dir: Direction) -> &[SimpleType] { + match dir { + Direction::Incoming => &self.input, + Direction::Outgoing => &self.output, + } + } + + /// Returns a slice of the input value types. + #[inline] + pub fn input_df_types(&self) -> &[SimpleType] { + self.df_types(Direction::Incoming) + } + + /// Returns a slice of the output value types. + #[inline] + pub fn output_df_types(&self) -> &[SimpleType] { + self.df_types(Direction::Outgoing) + } } impl Signature {