hugr_core::ops::handle

Trait NodeHandle

Source
pub trait NodeHandle: Clone {
    const TAG: OpTag;

    // Required method
    fn node(&self) -> Node;

    // Provided methods
    fn tag(&self) -> OpTag { ... }
    fn try_cast<T: NodeHandle + From<Node>>(&self) -> Option<T> { ... }
    fn can_hold(tag: OpTag) -> bool { ... }
}
Expand description

Common trait for handles to a node. Typically wrappers around Node.

Required Associated Constants§

Source

const TAG: OpTag

The most specific operation tag associated with the handle.

Required Methods§

Source

fn node(&self) -> Node

Index of underlying node.

Provided Methods§

Source

fn tag(&self) -> OpTag

Operation tag for the handle.

Source

fn try_cast<T: NodeHandle + From<Node>>(&self) -> Option<T>

Cast the handle to a different more general tag.

Source

fn can_hold(tag: OpTag) -> bool

Checks whether the handle can hold an operation with the given tag.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl NodeHandle for Node

Source§

const TAG: OpTag = OpTag::Any

Source§

impl NodeHandle for BasicBlockID

Source§

const TAG: OpTag = OpTag::DataflowBlock

Source§

impl NodeHandle for CaseID

Source§

const TAG: OpTag = OpTag::Case

Source§

impl NodeHandle for CfgID

Source§

const TAG: OpTag = OpTag::Cfg

Source§

impl NodeHandle for ConditionalID

Source§

const TAG: OpTag = OpTag::Conditional

Source§

impl NodeHandle for ConstID

Source§

const TAG: OpTag = OpTag::Const

Source§

impl NodeHandle for DataflowOpID

Source§

const TAG: OpTag = OpTag::DataflowChild

Source§

impl NodeHandle for DataflowParentID

Source§

const TAG: OpTag = OpTag::DataflowParent

Source§

impl NodeHandle for DfgID

Source§

const TAG: OpTag = OpTag::Dfg

Source§

impl NodeHandle for ModuleID

Source§

const TAG: OpTag = OpTag::ModuleOp

Source§

impl NodeHandle for ModuleRootID

Source§

const TAG: OpTag = OpTag::ModuleRoot

Source§

impl NodeHandle for TailLoopID

Source§

const TAG: OpTag = OpTag::TailLoop

Source§

impl<T: NodeHandle> NodeHandle for BuildHandle<T>

Source§

const TAG: OpTag = T::TAG

Source§

impl<const DEF: bool> NodeHandle for AliasID<DEF>

Source§

const TAG: OpTag = OpTag::Alias

Source§

impl<const DEF: bool> NodeHandle for FuncID<DEF>

Source§

const TAG: OpTag = OpTag::Function