Skip to content

Commit

Permalink
feat: add is_ variant methods to EdgeKind (#1768)
Browse files Browse the repository at this point in the history
Closes #1767
  • Loading branch information
ss2165 authored Dec 11, 2024
1 parent eef239f commit a866bb5
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions hugr-core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,46 @@ impl EdgeKind {
pub fn is_static(&self) -> bool {
matches!(self, EdgeKind::Const(_) | EdgeKind::Function(_))
}

/// Returns `true` if the edge kind is [`ControlFlow`].
///
/// [`ControlFlow`]: EdgeKind::ControlFlow
#[must_use]
pub fn is_control_flow(&self) -> bool {
matches!(self, Self::ControlFlow)
}

/// Returns `true` if the edge kind is [`Value`].
///
/// [`Value`]: EdgeKind::Value
#[must_use]
pub fn is_value(&self) -> bool {
matches!(self, Self::Value(..))
}

/// Returns `true` if the edge kind is [`Const`].
///
/// [`Const`]: EdgeKind::Const
#[must_use]
pub fn is_const(&self) -> bool {
matches!(self, Self::Const(..))
}

/// Returns `true` if the edge kind is [`Function`].
///
/// [`Function`]: EdgeKind::Function
#[must_use]
pub fn is_function(&self) -> bool {
matches!(self, Self::Function(..))
}

/// Returns `true` if the edge kind is [`StateOrder`].
///
/// [`StateOrder`]: EdgeKind::StateOrder
#[must_use]
pub fn is_state_order(&self) -> bool {
matches!(self, Self::StateOrder)
}
}

#[derive(
Expand Down

0 comments on commit a866bb5

Please sign in to comment.