Struct Module

Source
pub struct Module<'a> {
    pub root: RegionId,
    pub nodes: Vec<Node<'a>>,
    pub regions: Vec<Region<'a>>,
    pub terms: Vec<Term<'a>>,
}
Expand description

A module consisting of a hugr graph together with terms.

See ast::Module for the AST representation.

Fields§

§root: RegionId

The id of the root region.

§nodes: Vec<Node<'a>>

Table of Nodes.

§regions: Vec<Region<'a>>

Table of Regions.

§terms: Vec<Term<'a>>

Table of Terms.

Implementations§

Source§

impl<'a> Module<'a>

Source

pub fn get_node(&self, node_id: NodeId) -> Option<&Node<'a>>

Return the node data for a given node id.

Source

pub fn get_node_mut(&mut self, node_id: NodeId) -> Option<&mut Node<'a>>

Return a mutable reference to the node data for a given node id.

Source

pub fn insert_node(&mut self, node: Node<'a>) -> NodeId

Insert a new node into the module and return its id.

Source

pub fn get_term(&self, term_id: TermId) -> Option<&Term<'a>>

Return the term data for a given term id.

Returns Term::Wildcard when the term id is invalid.

Source

pub fn get_term_mut(&mut self, term_id: TermId) -> Option<&mut Term<'a>>

Return a mutable reference to the term data for a given term id.

Source

pub fn insert_term(&mut self, term: Term<'a>) -> TermId

Insert a new term into the module and return its id.

Source

pub fn get_region(&self, region_id: RegionId) -> Option<&Region<'a>>

Return the region data for a given region id.

Source

pub fn get_region_mut(&mut self, region_id: RegionId) -> Option<&mut Region<'a>>

Return a mutable reference to the region data for a given region id.

Source

pub fn insert_region(&mut self, region: Region<'a>) -> RegionId

Insert a new region into the module and return its id.

Source

pub fn view<S, V: View<'a, S>>(&'a self, src: S) -> Option<V>

Attempt to view a part of this module via a View instance.

Source

pub fn as_ast(&self) -> Option<Module>

Convert the module to the ast representation.

Trait Implementations§

Source§

impl<'a> Clone for Module<'a>

Source§

fn clone(&self) -> Module<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Module<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Module<'a>

Source§

fn default() -> Module<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> Hash for Module<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for Module<'a>

Source§

fn eq(&self, other: &Module<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for Module<'a>

Source§

impl<'a> StructuralPartialEq for Module<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Module<'a>

§

impl<'a> RefUnwindSafe for Module<'a>

§

impl<'a> Send for Module<'a>

§

impl<'a> Sync for Module<'a>

§

impl<'a> Unpin for Module<'a>

§

impl<'a> UnwindSafe for Module<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<'a, S, T> View<'a, &S> for T
where T: View<'a, S>, S: Copy,

Source§

fn view(module: &'a Module<'a>, id: &S) -> Option<T>

Attempt to interpret a subpart of a module as this type.