Struct Hugr

Source
pub struct Hugr { /* private fields */ }
Expand description

The Hugr data structure.

Implementations§

Source§

impl Hugr

Source

pub fn into_region_portgraph( self, parent: Node, ) -> FlatRegion<'static, MultiPortGraph>

Consumes the HUGR and return a flat portgraph view of the region rooted at parent.

Source§

impl Hugr

Public API for HUGRs.

Source

pub fn new() -> Self

Create a new Hugr, with a single Module operation as the root node.

Source

pub fn new_with_entrypoint( entrypoint_op: impl Into<OpType>, ) -> Result<Self, HugrError>

Create a new Hugr, with a given entrypoint operation.

If the optype is OpType::Module, the HUGR module root will match the entrypoint node. Otherwise, the entrypoint will be a descendent of the a module initialized at the node hierarchy root. The specific HUGR created depends on the operation type.

§Error

Returns HugrError::UnsupportedEntrypoint if the entrypoint operation requires additional context to be defined. This is the case for OpType::Case, OpType::DataflowBlock, and OpType::ExitBlock since they are context-specific definitions.

Source

pub fn with_capacity( entrypoint_op: impl Into<OpType>, nodes: usize, ports: usize, ) -> Result<Self, HugrError>

Create a new Hugr, with a given entrypoint operation and preallocated capacity.

If the optype is OpType::Module, the HUGR module root will match the entrypoint node. Otherwise, the entrypoint will be a child of the a module initialized at the node hierarchy root. The specific HUGR created depends on the operation type.

§Error

Returns HugrError::UnsupportedEntrypoint if the entrypoint operation requires additional context to be defined. This is the case for OpType::Case, OpType::DataflowBlock, and OpType::ExitBlock since they are context-specific definitions.

Source

pub fn reserve(&mut self, nodes: usize, links: usize)

Reserves enough capacity to insert at least the given number of additional nodes and links.

This method does not take into account already allocated free space left after node removals, and may overallocate capacity.

Source

pub fn load( reader: impl BufRead, extensions: Option<&ExtensionRegistry>, ) -> Result<Self, EnvelopeError>

Read a HUGR from an Envelope.

To load a HUGR, all the extensions used in its definition must be available. The Envelope may include some of the extensions, but any additional extensions must be provided in the extensions parameter. If extensions is None, the default crate::std_extensions::STD_REG is used.

Source

pub fn load_str( envelope: impl AsRef<str>, extensions: Option<&ExtensionRegistry>, ) -> Result<Self, EnvelopeError>

Read a HUGR from an Envelope encoded in a string.

Note that not all Envelopes are valid strings. In the general case, it is recommended to use Hugr::load with a bytearray instead.

To load a HUGR, all the extensions used in its definition must be available. The Envelope may include some of the extensions, but any additional extensions must be provided in the extensions parameter. If extensions is None, the default crate::std_extensions::STD_REG is used.

Source

pub fn store( &self, writer: impl Write, config: EnvelopeConfig, ) -> Result<(), EnvelopeError>

Store the HUGR in an Envelope.

The Envelope will not include any extension definition, and will require an adequate ExtensionRegistry to be loaded (see Hugr::load). Use Hugr::store_with_exts to include additional extensions in the Envelope.

Source

pub fn store_with_exts( &self, writer: impl Write, config: EnvelopeConfig, extensions: &ExtensionRegistry, ) -> Result<(), EnvelopeError>

Store the HUGR in an Envelope.

The Envelope will embed the definitions of the extensions in the extensions registry. Any other extension used in the HUGR definition must be passed to Hugr::load to load back the HUGR.

Source

pub fn store_str(&self, config: EnvelopeConfig) -> Result<String, EnvelopeError>

Store the HUGR in an Envelope encoded in a string.

Note that not all Envelopes are valid strings. In the general case, it is recommended to use Hugr::store with a bytearray instead. See EnvelopeFormat::ascii_printable.

The Envelope will not include any extension definition, and will require an adequate ExtensionRegistry to be loaded (see Hugr::load_str). Use Hugr::store_str_with_exts to include additional extensions in the Envelope.

Source

pub fn store_str_with_exts( &self, config: EnvelopeConfig, extensions: &ExtensionRegistry, ) -> Result<String, EnvelopeError>

Store the HUGR in an Envelope encoded in a string.

Note that not all Envelopes are valid strings. In the general case, it is recommended to use Hugr::store_str with a bytearray instead. See EnvelopeFormat::ascii_printable.

The Envelope will embed the definitions of the extensions in the extensions registry. Any other extension used in the HUGR definition must be passed to Hugr::load_str to load back the HUGR.

Source

pub fn resolve_extension_defs( &mut self, extensions: &ExtensionRegistry, ) -> Result<(), ExtensionResolutionError>

Given a Hugr that has been deserialized, collect all extensions used to define the HUGR while resolving all OpType::OpaqueOp operations into OpType::ExtensionOps and updating the extension pointer in all internal crate::types::CustomTypes to point to the extensions in the register.

When listing “used extensions” we only care about definitional extension requirements, i.e., the operations and types that are required to define the HUGR nodes and wire types. This is computed from the union of all extension required across the HUGR.

Updates the internal extension registry with the extensions used in the definition.

§Parameters
  • extensions: The extension set considered when resolving opaque operations and types. The original Hugr’s internal extension registry is ignored and replaced with the newly computed one.
§Errors
  • If an opaque operation cannot be resolved to an extension operation.
  • If an extension operation references an extension that is missing from the registry.
  • If a custom type references an extension that is missing from the registry.
Source§

impl Hugr

Internal API for HUGRs, not intended for use by users.

Source

pub fn canonicalize_nodes(&mut self, rekey: impl FnMut(Node, Node))

Compact the nodes indices of the hugr to be contiguous, and order them as a breadth-first traversal of the hierarchy.

The rekey function is called for each moved node with the old and new indices.

After this operation, a serialization and deserialization of the Hugr is guaranteed to preserve the indices.

Trait Implementations§

Source§

impl AsMut<Hugr> for Hugr

Source§

fn as_mut(&mut self) -> &mut Hugr

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<Hugr> for Hugr

Source§

fn as_ref(&self) -> &Hugr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<H: AsRef<Hugr>, Handle> AsRef<Hugr> for RootChecked<H, Handle>

Source§

fn as_ref(&self) -> &Hugr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Hugr

Source§

fn clone(&self) -> Hugr

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 Debug for Hugr

Source§

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

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

impl Default for Hugr

Source§

fn default() -> Self

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

impl<'de> DeserializeAs<'de, Hugr> for AsStringEnvelope

Source§

fn deserialize_as<D>(deserializer: D) -> Result<Hugr, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer.
Source§

impl HugrInternals for Hugr

Source§

type RegionPortgraph<'p> = &'p MultiPortGraph where Self: 'p

The portgraph graph structure returned by HugrInternals::region_portgraph.
Source§

type Node = Node

The type of nodes in the Hugr.
Source§

type RegionPortgraphNodes = DefaultPGNodeMap

A mapping between HUGR nodes and portgraph nodes in the graph returned by HugrInternals::region_portgraph.
Source§

fn region_portgraph( &self, parent: Self::Node, ) -> (FlatRegion<'_, Self::RegionPortgraph<'_>>, Self::RegionPortgraphNodes)

Returns a flat portgraph view of a region in the HUGR, and a mapping between HUGR nodes and portgraph nodes in the graph.
Source§

fn node_metadata_map(&self, node: Self::Node) -> &NodeMetadataMap

Returns a metadata entry associated with a node. Read more
Source§

impl HugrMut for Hugr

Impl for non-wrapped Hugrs. Overwrites the recursive default-impls to directly use the hugr.

Source§

fn set_entrypoint(&mut self, root: Node)

Set entrypoint to the HUGR. Read more
Source§

fn get_metadata_mut( &mut self, node: Self::Node, key: impl AsRef<str>, ) -> &mut NodeMetadata

Returns a metadata entry associated with a node. Read more
Source§

fn set_metadata( &mut self, node: Self::Node, key: impl AsRef<str>, metadata: impl Into<NodeMetadata>, )

Sets a metadata value associated with a node. Read more
Source§

fn remove_metadata(&mut self, node: Self::Node, key: impl AsRef<str>)

Remove a metadata entry associated with a node. Read more
Source§

fn add_node_with_parent( &mut self, parent: Node, node: impl Into<OpType>, ) -> Node

Add a node to the graph with a parent in the hierarchy. Read more
Source§

fn add_node_before( &mut self, sibling: Node, nodetype: impl Into<OpType>, ) -> Node

Add a node to the graph as the previous sibling of another node. Read more
Source§

fn add_node_after(&mut self, sibling: Node, op: impl Into<OpType>) -> Node

Add a node to the graph as the next sibling of another node. Read more
Source§

fn remove_node(&mut self, node: Node) -> OpType

Remove a node from the graph and return the node weight. Note that if the node has children, they are not removed; this leaves the Hugr in an invalid state. See Self::remove_subtree. Read more
Source§

fn remove_subtree(&mut self, node: Node)

Remove a node from the graph, along with all its descendants in the hierarchy. Read more
Source§

fn connect( &mut self, src: Node, src_port: impl Into<OutgoingPort>, dst: Node, dst_port: impl Into<IncomingPort>, )

Connect two nodes at the given ports. Read more
Source§

fn disconnect(&mut self, node: Node, port: impl Into<Port>)

Disconnects all edges from the given port. Read more
Source§

fn add_other_edge( &mut self, src: Node, dst: Node, ) -> (OutgoingPort, IncomingPort)

Adds a non-dataflow edge between two nodes. The kind is given by the operation’s OpTrait::other_input or OpTrait::other_output. Read more
Source§

fn insert_hugr( &mut self, root: Self::Node, other: Hugr, ) -> InsertionResult<Node, Self::Node>

Insert another hugr into this one, under a given parent node. Read more
Source§

fn insert_from_view<H: HugrView>( &mut self, root: Self::Node, other: &H, ) -> InsertionResult<H::Node, Self::Node>

Copy another hugr into this one, under a given parent node. Read more
Source§

fn insert_subgraph<H: HugrView>( &mut self, root: Self::Node, other: &H, subgraph: &SiblingSubgraph<H::Node>, ) -> HashMap<H::Node, Self::Node>

Copy a subgraph from another hugr into this one, under a given parent node. Read more
Source§

fn copy_descendants( &mut self, root: Self::Node, new_parent: Self::Node, subst: Option<Substitution<'_>>, ) -> BTreeMap<Self::Node, Self::Node>

Copies the strict descendants of root to under the new_parent, optionally applying a Substitution to the OpTypes of the copied nodes. Read more
Source§

fn use_extension(&mut self, extension: impl Into<Arc<Extension>>)

Registers a new extension in the set used by the hugr, keeping the one most recent one if the extension already exists. Read more
Source§

fn use_extensions<Reg>(&mut self, registry: impl IntoIterator<Item = Reg>)

Extend the set of extensions used by the hugr with the extensions in the registry. Read more
Source§

fn with_entrypoint_mut(&mut self, entrypoint: Self::Node) -> Rerooted<&mut Self>
where Self: Sized,

Returns a mutable view of the HUGR with a different entrypoint. Read more
Source§

fn apply_patch<R, E>( &mut self, rw: impl Patch<Self, Outcome = R, Error = E>, ) -> Result<R, E>
where Self: Sized,

Applies a patch to the graph.
Source§

impl HugrMutInternals for Hugr

Impl for non-wrapped Hugrs. Overwrites the recursive default-impls to directly use the hugr.

Source§

fn set_module_root(&mut self, root: Node)

Set the node at the root of the HUGR hierarchy. Read more
Source§

fn set_num_ports(&mut self, node: Node, incoming: usize, outgoing: usize)

Set the number of ports on a node. This may invalidate the node’s PortIndex. Read more
Source§

fn add_ports( &mut self, node: Node, direction: Direction, amount: isize, ) -> Range<usize>

Alter the number of ports on a node and returns a range with the new port offsets, if any. This may invalidate the node’s PortIndex. Read more
Source§

fn insert_ports( &mut self, node: Node, direction: Direction, index: usize, amount: usize, ) -> Range<usize>

Insert amount new ports for a node, starting at index. The direction parameter specifies whether to add ports to the incoming or outgoing list. Links from this node are preserved, even when ports are renumbered by the insertion. Read more
Source§

fn set_parent(&mut self, node: Node, parent: Node)

Sets the parent of a node. Read more
Source§

fn move_after_sibling(&mut self, node: Node, after: Node)

Move a node in the hierarchy to be the subsequent sibling of another node. Read more
Source§

fn move_before_sibling(&mut self, node: Node, before: Node)

Move a node in the hierarchy to be the prior sibling of another node. Read more
Source§

fn replace_op(&mut self, node: Node, op: impl Into<OpType>) -> OpType

Replace the OpType at node and return the old OpType. In general this invalidates the ports, which may need to be resized to match the OpType signature. Read more
Source§

fn optype_mut(&mut self, node: Node) -> &mut OpType

Gets a mutable reference to the optype. Read more
Source§

fn node_metadata_map_mut(&mut self, node: Self::Node) -> &mut NodeMetadataMap

Returns a metadata entry associated with a node. Read more
Source§

fn extensions_mut(&mut self) -> &mut ExtensionRegistry

Returns a mutable reference to the extension registry for this HUGR. Read more
Source§

impl HugrView for Hugr

Source§

fn entrypoint(&self) -> Self::Node

The distinguished node from where operations are applied, commonly defining a region of interest. Read more
Source§

fn module_root(&self) -> Self::Node

A pointer to the module region defined at the root of the HUGR. Read more
Source§

fn contains_node(&self, node: Self::Node) -> bool

Returns true if the node exists in the HUGR.
Source§

fn get_parent(&self, node: Self::Node) -> Option<Self::Node>

Returns the parent of a node.
Source§

fn get_optype(&self, node: Node) -> &OpType

Returns the operation type of a node. Read more
Source§

fn num_nodes(&self) -> usize

Returns the number of nodes in the HUGR.
Source§

fn num_edges(&self) -> usize

Returns the number of edges in the HUGR.
Source§

fn num_ports(&self, node: Self::Node, dir: Direction) -> usize

Number of ports in node for a given direction.
Source§

fn nodes(&self) -> impl Iterator<Item = Node> + Clone

Iterates over the all the nodes in the HUGR. Read more
Source§

fn node_ports( &self, node: Node, dir: Direction, ) -> impl Iterator<Item = Port> + Clone

Iterator over ports of node in a given direction.
Source§

fn all_node_ports(&self, node: Node) -> impl Iterator<Item = Port> + Clone

Iterator over both the input and output ports of node.
Source§

fn linked_ports( &self, node: Node, port: impl Into<Port>, ) -> impl Iterator<Item = (Node, Port)> + Clone

Iterator over the nodes and ports connected to a port.
Source§

fn node_connections( &self, node: Node, other: Node, ) -> impl Iterator<Item = [Port; 2]> + Clone

Iterator the links between two nodes.
Source§

fn children( &self, node: Self::Node, ) -> impl DoubleEndedIterator<Item = Self::Node> + Clone

Returns an iterator over the direct children of node.
Source§

fn descendants( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Node> + Clone

Returns an iterator over all the descendants of a node, including the node itself. Read more
Source§

fn neighbours( &self, node: Node, dir: Direction, ) -> impl Iterator<Item = Node> + Clone

Iterates over neighbour nodes in the given direction. May contain duplicates if the graph has multiple links between nodes.
Source§

fn all_neighbours(&self, node: Node) -> impl Iterator<Item = Node> + Clone

Iterates over the input and output neighbours of the node in sequence.
Source§

fn mermaid_string_with_config(&self, config: RenderConfig) -> String

👎Deprecated: Use mermaid_format instead
Return the mermaid representation of the underlying hierarchical graph. Read more
Source§

fn mermaid_string_with_formatter( &self, formatter: MermaidFormatter<'_, Self>, ) -> String

Return the mermaid representation of the underlying hierarchical graph according to the provided MermaidFormatter formatting options. Read more
Source§

fn dot_string(&self) -> String
where Self: Sized,

Return the graphviz representation of the underlying graph and hierarchy side by side. Read more
Source§

fn extensions(&self) -> &ExtensionRegistry

Returns the set of extensions used by the HUGR. Read more
Source§

fn extract_hugr( &self, target: Node, ) -> (Hugr, impl ExtractionResult<Node> + 'static)

Extracts a HUGR containing the parent node and all its descendants. Read more
Source§

fn entrypoint_optype(&self) -> &OpType

Returns the operation type of the entrypoint node.
Source§

fn entrypoint_tag(&self) -> OpTag

An operation tag that is guaranteed to represent the HugrView::entrypoint node operation. Read more
Source§

fn with_entrypoint(&self, entrypoint: Self::Node) -> Rerooted<&Self>
where Self: Sized,

Returns a non-mutable view of the HUGR with a different entrypoint. Read more
Source§

fn get_metadata( &self, node: Self::Node, key: impl AsRef<str>, ) -> Option<&NodeMetadata>

Returns the metadata associated with a node.
Source§

fn num_inputs(&self, node: Self::Node) -> usize

Number of inputs to a node. Shorthand for num_ports(node, Direction::Incoming).
Source§

fn num_outputs(&self, node: Self::Node) -> usize

Number of outputs from a node. Shorthand for num_ports(node, Direction::Outgoing).
Source§

fn node_outputs( &self, node: Self::Node, ) -> impl Iterator<Item = OutgoingPort> + Clone

Iterator over output ports of node. Like node_ports(node, Direction::Outgoing) but preserves knowledge that the ports are OutgoingPorts.
Source§

fn node_inputs( &self, node: Self::Node, ) -> impl Iterator<Item = IncomingPort> + Clone

Iterator over inputs ports of node. Like node_ports(node, Direction::Incoming) but preserves knowledge that the ports are IncomingPorts.
Source§

fn all_linked_ports( &self, node: Self::Node, dir: Direction, ) -> Either<impl Iterator<Item = (Self::Node, OutgoingPort)>, impl Iterator<Item = (Self::Node, IncomingPort)>>

Iterator over all the nodes and ports connected to a node in a given direction.
Source§

fn all_linked_outputs( &self, node: Self::Node, ) -> impl Iterator<Item = (Self::Node, OutgoingPort)>

Iterator over all the nodes and ports connected to a node’s inputs.
Source§

fn all_linked_inputs( &self, node: Self::Node, ) -> impl Iterator<Item = (Self::Node, IncomingPort)>

Iterator over all the nodes and ports connected to a node’s outputs.
Source§

fn single_linked_port( &self, node: Self::Node, port: impl Into<Port>, ) -> Option<(Self::Node, Port)>

If there is exactly one port connected to this port, return it and its node.
Source§

fn single_linked_output( &self, node: Self::Node, port: impl Into<IncomingPort>, ) -> Option<(Self::Node, OutgoingPort)>

If there is exactly one OutgoingPort connected to this IncomingPort, return it and its node.
Source§

fn single_linked_input( &self, node: Self::Node, port: impl Into<OutgoingPort>, ) -> Option<(Self::Node, IncomingPort)>

If there is exactly one IncomingPort connected to this OutgoingPort, return it and its node.
Source§

fn linked_outputs( &self, node: Self::Node, port: impl Into<IncomingPort>, ) -> impl Iterator<Item = (Self::Node, OutgoingPort)>

Iterator over the nodes and output ports connected to a given input port. Like linked_ports but preserves knowledge that the linked ports are OutgoingPorts.
Source§

fn linked_inputs( &self, node: Self::Node, port: impl Into<OutgoingPort>, ) -> impl Iterator<Item = (Self::Node, IncomingPort)>

Iterator over the nodes and input ports connected to a given output port Like linked_ports but preserves knowledge that the linked ports are IncomingPorts.
Source§

fn is_linked(&self, node: Self::Node, port: impl Into<Port>) -> bool

Returns whether a port is connected.
Source§

fn entry_descendants(&self) -> impl Iterator<Item = Self::Node> + Clone

Returns an iterator over all the descendants of the hugr entrypoint, including the node itself. Read more
Source§

fn first_child(&self, node: Self::Node) -> Option<Self::Node>

Returns the first child of the specified node (if it is a parent). Useful because x.children().next() leaves x borrowed.
Source§

fn input_neighbours( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Node> + Clone

Iterates over the input neighbours of the node. Shorthand for neighbours(node, Direction::Incoming).
Source§

fn output_neighbours( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Node> + Clone

Iterates over the output neighbours of the node. Shorthand for neighbours(node, Direction::Outgoing).
Source§

fn get_io(&self, node: Self::Node) -> Option<[Self::Node; 2]>

Get the input and output child nodes of a dataflow parent. If the node isn’t a dataflow parent, then return None
Source§

fn inner_function_type(&self) -> Option<Cow<'_, Signature>>

Returns the function type defined by this dataflow HUGR. Read more
Source§

fn poly_func_type(&self) -> Option<PolyFuncType>

Returns the function type defined by this HUGR, i.e. Some iff the root is a FuncDecl or FuncDefn.
Source§

fn as_petgraph(&self) -> PetgraphWrapper<'_, Self>
where Self: Sized,

Return a wrapper over the view that can be used in petgraph algorithms.
Source§

fn mermaid_string(&self) -> String

Return the mermaid representation of the underlying hierarchical graph. Read more
Source§

fn mermaid_format(&self) -> MermaidFormatter<'_, Self>

Construct a mermaid representation of the underlying hierarchical graph. Read more
Source§

fn static_source(&self, node: Self::Node) -> Option<Self::Node>

If a node has a static input, return the source node.
Source§

fn static_targets( &self, node: Self::Node, ) -> Option<impl Iterator<Item = (Self::Node, IncomingPort)>>

If a node has a static output, return the targets.
Source§

fn signature(&self, node: Self::Node) -> Option<Cow<'_, Signature>>

Get the “signature” (incoming and outgoing types) of a node, non-Value kind ports will be missing.
Source§

fn value_types( &self, node: Self::Node, dir: Direction, ) -> impl Iterator<Item = (Port, Type)>

Iterator over all outgoing ports that have Value type, along with corresponding types.
Source§

fn in_value_types( &self, node: Self::Node, ) -> impl Iterator<Item = (IncomingPort, Type)>

Iterator over all incoming ports that have Value type, along with corresponding types.
Source§

fn out_value_types( &self, node: Self::Node, ) -> impl Iterator<Item = (OutgoingPort, Type)>

Iterator over all outgoing ports that have Value type, along with corresponding types.
Source§

fn validate(&self) -> Result<(), ValidationError<Self::Node>>
where Self: Sized,

Check the validity of the underlying HUGR.
Source§

impl PartialEq for Hugr

Source§

fn eq(&self, other: &Hugr) -> 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 SerializeAs<Hugr> for AsStringEnvelope

Source§

fn serialize_as<S>(source: &Hugr, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer.
Source§

impl StructuralPartialEq for Hugr

Auto Trait Implementations§

§

impl !Freeze for Hugr

§

impl !RefUnwindSafe for Hugr

§

impl Send for Hugr

§

impl Sync for Hugr

§

impl Unpin for Hugr

§

impl !UnwindSafe for Hugr

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<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<H, Handle> RootCheckable<H, Handle> for H
where H: HugrView, Handle: NodeHandle<<H as HugrInternals>::Node>,

Source§

fn try_into_checked(self) -> Result<RootChecked<H, Handle>, HugrError>

Wrap the Hugr in a RootChecked if it is valid for the required OpTag. Read more
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more