pub struct PersistentHugr { /* private fields */ }
Expand description
A HUGR-like object that tracks its mutation history.
When mutations are applied to a PersistentHugr
, the object is mutated
as expected but all references to previous versions of the object remain
valid. Furthermore, older versions of the data can be recovered by
traversing the object’s history with Self::as_state_space
.
Multiple references to various versions of a Hugr can be maintained in
parallel by extracting them from a shared CommitStateSpace
.
§Supported access and mutation
PersistentHugr
implements crate::HugrView
, so that it can used as
a drop-in substitute for a Hugr wherever read-only access is required. It
does not implement HugrMut
, however. Mutations
must be performed by applying patches (see PatchVerification
and
Patch
). Currently, only SimpleReplacement
patches are supported. You
can use Self::add_replacement
to add a patch to self
, or use the
aforementioned patch traits.
§Patches, commits and history
A PersistentHugr
is composed of a unique base HUGR, along with a set of
mutations applied to it. All mutations are stored in the form of commits
that store the patches applied on top of a base HUGR. You may think of it
as a “queue” of patches: whenever the patch of a commit is “applied”, it is
in reality just added to the queue. In practice, the total order of the
queue is irrelevant, as patches only depend on a subset of the previously
applied patches. This creates a partial order on the commits: a directed
acyclic graph that we call the “commit history”. A commit history is in
effect a subgraph of a commit state space, with the additional invariant
that all commits within the history are compatible.
§Supported graph types
Currently, only patches that apply to subgraphs within dataflow regions are supported.
Implementations§
Source§impl PersistentHugr
impl PersistentHugr
Sourcepub fn with_base(hugr: Hugr) -> Self
pub fn with_base(hugr: Hugr) -> Self
Create a PersistentHugr
with hugr
as its base HUGR.
All replacements added in the future will apply on top of hugr
.
Sourcepub fn from_commit(commit: Commit) -> Self
pub fn from_commit(commit: Commit) -> Self
Create a PersistentHugr
from a single commit and its ancestors.
Sourcepub fn try_new(
commits: impl IntoIterator<Item = Commit>,
) -> Result<Self, InvalidCommit>
pub fn try_new( commits: impl IntoIterator<Item = Commit>, ) -> Result<Self, InvalidCommit>
Create a PersistentHugr
from a list of commits.
Self
will correspond to the HUGR obtained by applying the patches of
the given commits and of all their ancestors.
If the state space of the commits would include two commits which are incompatible, or if the commits do not share a common base HUGR, then an error is returned.
Sourcepub fn add_replacement(
&mut self,
replacement: PersistentReplacement,
) -> CommitId
pub fn add_replacement( &mut self, replacement: PersistentReplacement, ) -> CommitId
Add a replacement to self
.
The effect of this is equivalent to applying replacement
to the
equivalent HUGR, i.e. self.to_hugr().apply(replacement)
is
equivalent to self.add_replacement(replacement).to_hugr()
.
This will panic if the replacement is invalid. Use
PersistentHugr::try_add_replacement
instead for more graceful error
handling.
Sourcepub fn try_add_replacement(
&mut self,
replacement: PersistentReplacement,
) -> Result<CommitId, InvalidCommit>
pub fn try_add_replacement( &mut self, replacement: PersistentReplacement, ) -> Result<CommitId, InvalidCommit>
Add a replacement to self
, with error handling.
All parent commits must already be in self
.
Return the ID of) the commit if it was added successfully. This may return the following errors:
- a
InvalidCommit::IncompatibleHistory
error if the replacement is incompatible with another commit already inself
, or - a
InvalidCommit::UnknownParent
error if one of the commits thatreplacement
applies on top of is not contained inself
.
Sourcepub fn try_add_commit(
&mut self,
commit: Commit,
) -> Result<CommitId, InvalidCommit>
pub fn try_add_commit( &mut self, commit: Commit, ) -> Result<CommitId, InvalidCommit>
Add a commit to self
and all its ancestors.
The commit and all its ancestors must be compatible with all existing
commits in self
. If this is not satisfied, an
InvalidCommit::IncompatibleHistory
error is returned. In this case,
as many compatible commits as possible are added to self
.
Sourcepub fn to_hugr(&self) -> Hugr
pub fn to_hugr(&self) -> Hugr
Convert this PersistentHugr
to a materialized Hugr by applying all
commits in self
.
This operation may be expensive and should be avoided in
performance-critical paths. For read-only views into the data, rely
instead on the crate::HugrView
implementation when possible.
Sourcepub fn apply_all(&self) -> (Hugr, HashMap<PatchNode, Node>)
pub fn apply_all(&self) -> (Hugr, HashMap<PatchNode, Node>)
Apply all commits in self
to the base HUGR.
Also returns a map from the nodes of the base HUGR to the nodes of the materialized HUGR.
Sourcepub fn as_state_space(&self) -> &CommitStateSpace
pub fn as_state_space(&self) -> &CommitStateSpace
Get a reference to the underlying state space of self
.
Sourcepub fn into_state_space(self) -> CommitStateSpace
pub fn into_state_space(self) -> CommitStateSpace
Convert self
into its underlying CommitStateSpace
.
Sourcepub fn contains_id(&self, commit_id: CommitId) -> bool
pub fn contains_id(&self, commit_id: CommitId) -> bool
Check if commit_id
is in the PersistentHugr.
Sourcepub fn base_commit(&self) -> &Commit
pub fn base_commit(&self) -> &Commit
Get the base commit.
Sourcepub fn get_commit(&self, commit_id: CommitId) -> &Commit
pub fn get_commit(&self, commit_id: CommitId) -> &Commit
Get the commit with ID commit_id
.
Sourcepub fn inserted_nodes(
&self,
commit_id: CommitId,
) -> impl Iterator<Item = PatchNode> + '_
pub fn inserted_nodes( &self, commit_id: CommitId, ) -> impl Iterator<Item = PatchNode> + '_
Get an iterator over all nodes inserted by commit_id
.
All nodes will be PatchNodes with commit ID commit_id
.
Sourcepub fn all_commit_ids(&self) -> impl Iterator<Item = CommitId> + Clone + '_
pub fn all_commit_ids(&self) -> impl Iterator<Item = CommitId> + Clone + '_
Get an iterator over all commit IDs in the persistent HUGR.
Sourcepub fn invalidation_set(
&self,
commit_id: CommitId,
) -> impl Iterator<Item = Node> + '_
pub fn invalidation_set( &self, commit_id: CommitId, ) -> impl Iterator<Item = Node> + '_
Get the set of nodes of commit_id
that are invalidated by the patches
in the children commits of commit_id
.
The invalidation set must include all nodes that are deleted by the
children commits (as returned by Self::deleted_nodes
), but may
also include further nodes to enforce stricter exclusivity constraints
between patches.
Sourcepub fn deleted_nodes(
&self,
commit_id: CommitId,
) -> impl Iterator<Item = Node> + '_
pub fn deleted_nodes( &self, commit_id: CommitId, ) -> impl Iterator<Item = Node> + '_
Get the set of nodes of commit_id
that are deleted by applying
the children commits of commit_id
.
This is a subset of Self::invalidation_set
. Whilst the latter is
used to establish exclusivity constraints between patches, this method
is used when we are computing the set of nodes currently present in
self
.
Sourcepub fn contains_node(&self, PatchNode: PatchNode) -> bool
pub fn contains_node(&self, PatchNode: PatchNode) -> bool
Check if a patch node is in the PersistentHugr, that is, it belongs to a commit in the state space and is not deleted by any child commit.
Trait Implementations§
Source§impl Clone for PersistentHugr
impl Clone for PersistentHugr
Source§fn clone(&self) -> PersistentHugr
fn clone(&self) -> PersistentHugr
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PersistentHugr
impl Debug for PersistentHugr
Source§impl HugrInternals for PersistentHugr
impl HugrInternals for PersistentHugr
Source§type RegionPortgraph<'p> = MultiPortGraph
where
Self: 'p
type RegionPortgraph<'p> = MultiPortGraph where Self: 'p
HugrInternals::region_portgraph
.Source§type RegionPortgraphNodes = HashMap<PatchNode, Node>
type RegionPortgraphNodes = HashMap<PatchNode, Node>
HugrInternals::region_portgraph
.Source§fn region_portgraph(
&self,
parent: Self::Node,
) -> (FlatRegion<'_, Self::RegionPortgraph<'_>>, Self::RegionPortgraphNodes)
fn region_portgraph( &self, parent: Self::Node, ) -> (FlatRegion<'_, Self::RegionPortgraph<'_>>, Self::RegionPortgraphNodes)
Source§fn node_metadata_map(&self, node: Self::Node) -> &NodeMetadataMap
fn node_metadata_map(&self, node: Self::Node) -> &NodeMetadataMap
Source§impl HugrView for PersistentHugr
impl HugrView for PersistentHugr
Source§fn entrypoint(&self) -> Self::Node
fn entrypoint(&self) -> Self::Node
Source§fn module_root(&self) -> Self::Node
fn module_root(&self) -> Self::Node
Source§fn contains_node(&self, node: Self::Node) -> bool
fn contains_node(&self, node: Self::Node) -> bool
true
if the node exists in the HUGR.Source§fn get_optype(&self, node: Self::Node) -> &OpType
fn get_optype(&self, node: Self::Node) -> &OpType
Source§fn num_ports(&self, node: Self::Node, dir: Direction) -> usize
fn num_ports(&self, node: Self::Node, dir: Direction) -> usize
Source§fn nodes(&self) -> impl Iterator<Item = Self::Node> + Clone
fn nodes(&self) -> impl Iterator<Item = Self::Node> + Clone
Source§fn node_ports(
&self,
node: Self::Node,
dir: Direction,
) -> impl Iterator<Item = Port> + Clone
fn node_ports( &self, node: Self::Node, dir: Direction, ) -> impl Iterator<Item = Port> + Clone
Source§fn all_node_ports(&self, node: Self::Node) -> impl Iterator<Item = Port> + Clone
fn all_node_ports(&self, node: Self::Node) -> impl Iterator<Item = Port> + Clone
Source§fn linked_ports(
&self,
node: Self::Node,
port: impl Into<Port>,
) -> impl Iterator<Item = (Self::Node, Port)> + Clone
fn linked_ports( &self, node: Self::Node, port: impl Into<Port>, ) -> impl Iterator<Item = (Self::Node, Port)> + Clone
Source§fn node_connections(
&self,
node: Self::Node,
other: Self::Node,
) -> impl Iterator<Item = [Port; 2]> + Clone
fn node_connections( &self, node: Self::Node, other: Self::Node, ) -> impl Iterator<Item = [Port; 2]> + Clone
Source§fn children(
&self,
node: Self::Node,
) -> impl DoubleEndedIterator<Item = Self::Node> + Clone
fn children( &self, node: Self::Node, ) -> impl DoubleEndedIterator<Item = Self::Node> + Clone
Source§fn descendants(
&self,
node: Self::Node,
) -> impl Iterator<Item = Self::Node> + Clone
fn descendants( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Node> + Clone
Source§fn neighbours(
&self,
node: Self::Node,
dir: Direction,
) -> impl Iterator<Item = Self::Node> + Clone
fn neighbours( &self, node: Self::Node, dir: Direction, ) -> impl Iterator<Item = Self::Node> + Clone
Source§fn all_neighbours(
&self,
node: Self::Node,
) -> impl Iterator<Item = Self::Node> + Clone
fn all_neighbours( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Node> + Clone
node
in sequence.Source§fn mermaid_string(&self) -> String
fn mermaid_string(&self) -> String
Source§fn mermaid_string_with_config(&self, config: RenderConfig<Self::Node>) -> String
fn mermaid_string_with_config(&self, config: RenderConfig<Self::Node>) -> String
Source§fn dot_string(&self) -> Stringwhere
Self: Sized,
fn dot_string(&self) -> Stringwhere
Self: Sized,
Source§fn extensions(&self) -> &ExtensionRegistry
fn extensions(&self) -> &ExtensionRegistry
Source§fn extract_hugr(
&self,
parent: Self::Node,
) -> (Hugr, impl ExtractionResult<Self::Node> + 'static)
fn extract_hugr( &self, parent: Self::Node, ) -> (Hugr, impl ExtractionResult<Self::Node> + 'static)
Source§fn entrypoint_optype(&self) -> &OpType
fn entrypoint_optype(&self) -> &OpType
Source§fn entrypoint_tag(&self) -> OpTag
fn entrypoint_tag(&self) -> OpTag
HugrView::entrypoint
node operation. Read moreSource§fn with_entrypoint(&self, entrypoint: Self::Node) -> Rerooted<&Self>where
Self: Sized,
fn with_entrypoint(&self, entrypoint: Self::Node) -> Rerooted<&Self>where
Self: Sized,
Source§fn get_metadata(
&self,
node: Self::Node,
key: impl AsRef<str>,
) -> Option<&NodeMetadata>
fn get_metadata( &self, node: Self::Node, key: impl AsRef<str>, ) -> Option<&NodeMetadata>
Source§fn num_inputs(&self, node: Self::Node) -> usize
fn num_inputs(&self, node: Self::Node) -> usize
num_ports
(node, Direction::Incoming)
.Source§fn num_outputs(&self, node: Self::Node) -> usize
fn num_outputs(&self, node: Self::Node) -> usize
num_ports
(node, Direction::Outgoing)
.Source§fn node_outputs(
&self,
node: Self::Node,
) -> impl Iterator<Item = OutgoingPort> + Clone
fn node_outputs( &self, node: Self::Node, ) -> impl Iterator<Item = OutgoingPort> + Clone
node_ports
(node, Direction::Outgoing)
but preserves knowledge that the ports are OutgoingPort
s.Source§fn node_inputs(
&self,
node: Self::Node,
) -> impl Iterator<Item = IncomingPort> + Clone
fn node_inputs( &self, node: Self::Node, ) -> impl Iterator<Item = IncomingPort> + Clone
node_ports
(node, Direction::Incoming)
but preserves knowledge that the ports are IncomingPort
s.Source§fn all_linked_ports(
&self,
node: Self::Node,
dir: Direction,
) -> Either<impl Iterator<Item = (Self::Node, OutgoingPort)>, impl Iterator<Item = (Self::Node, IncomingPort)>> ⓘ
fn all_linked_ports( &self, node: Self::Node, dir: Direction, ) -> Either<impl Iterator<Item = (Self::Node, OutgoingPort)>, impl Iterator<Item = (Self::Node, IncomingPort)>> ⓘ
Source§fn all_linked_outputs(
&self,
node: Self::Node,
) -> impl Iterator<Item = (Self::Node, OutgoingPort)>
fn all_linked_outputs( &self, node: Self::Node, ) -> impl Iterator<Item = (Self::Node, OutgoingPort)>
Source§fn all_linked_inputs(
&self,
node: Self::Node,
) -> impl Iterator<Item = (Self::Node, IncomingPort)>
fn all_linked_inputs( &self, node: Self::Node, ) -> impl Iterator<Item = (Self::Node, IncomingPort)>
Source§fn single_linked_port(
&self,
node: Self::Node,
port: impl Into<Port>,
) -> Option<(Self::Node, Port)>
fn single_linked_port( &self, node: Self::Node, port: impl Into<Port>, ) -> Option<(Self::Node, Port)>
Source§fn single_linked_output(
&self,
node: Self::Node,
port: impl Into<IncomingPort>,
) -> Option<(Self::Node, OutgoingPort)>
fn single_linked_output( &self, node: Self::Node, port: impl Into<IncomingPort>, ) -> Option<(Self::Node, OutgoingPort)>
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)>
fn single_linked_input( &self, node: Self::Node, port: impl Into<OutgoingPort>, ) -> Option<(Self::Node, IncomingPort)>
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)>
fn linked_outputs( &self, node: Self::Node, port: impl Into<IncomingPort>, ) -> impl Iterator<Item = (Self::Node, OutgoingPort)>
linked_ports
but preserves knowledge
that the linked ports are OutgoingPort
s.Source§fn linked_inputs(
&self,
node: Self::Node,
port: impl Into<OutgoingPort>,
) -> impl Iterator<Item = (Self::Node, IncomingPort)>
fn linked_inputs( &self, node: Self::Node, port: impl Into<OutgoingPort>, ) -> impl Iterator<Item = (Self::Node, IncomingPort)>
linked_ports
but preserves knowledge
that the linked ports are IncomingPort
s.Source§fn is_linked(&self, node: Self::Node, port: impl Into<Port>) -> bool
fn is_linked(&self, node: Self::Node, port: impl Into<Port>) -> bool
Source§fn entry_descendants(&self) -> impl Iterator<Item = Self::Node> + Clone
fn entry_descendants(&self) -> impl Iterator<Item = Self::Node> + Clone
Source§fn first_child(&self, node: Self::Node) -> Option<Self::Node>
fn first_child(&self, node: Self::Node) -> Option<Self::Node>
x.children().next()
leaves x borrowed.Source§fn input_neighbours(
&self,
node: Self::Node,
) -> impl Iterator<Item = Self::Node> + Clone
fn input_neighbours( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Node> + Clone
node
.
Shorthand for neighbours
(node, Direction::Incoming)
.Source§fn output_neighbours(
&self,
node: Self::Node,
) -> impl Iterator<Item = Self::Node> + Clone
fn output_neighbours( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Node> + Clone
node
.
Shorthand for neighbours
(node, Direction::Outgoing)
.Source§fn get_io(&self, node: Self::Node) -> Option<[Self::Node; 2]>
fn get_io(&self, node: Self::Node) -> Option<[Self::Node; 2]>
Source§fn inner_function_type(&self) -> Option<Cow<'_, Signature>>
fn inner_function_type(&self) -> Option<Cow<'_, Signature>>
Source§fn poly_func_type(&self) -> Option<PolyFuncType>
fn poly_func_type(&self) -> Option<PolyFuncType>
Source§fn as_petgraph(&self) -> PetgraphWrapper<'_, Self>where
Self: Sized,
fn as_petgraph(&self) -> PetgraphWrapper<'_, Self>where
Self: Sized,
Source§fn static_source(&self, node: Self::Node) -> Option<Self::Node>
fn static_source(&self, node: Self::Node) -> Option<Self::Node>
Source§fn static_targets(
&self,
node: Self::Node,
) -> Option<impl Iterator<Item = (Self::Node, IncomingPort)>>
fn static_targets( &self, node: Self::Node, ) -> Option<impl Iterator<Item = (Self::Node, IncomingPort)>>
Source§fn signature(&self, node: Self::Node) -> Option<Cow<'_, Signature>>
fn signature(&self, node: Self::Node) -> Option<Cow<'_, Signature>>
Source§fn value_types(
&self,
node: Self::Node,
dir: Direction,
) -> impl Iterator<Item = (Port, Type)>
fn value_types( &self, node: Self::Node, dir: Direction, ) -> impl Iterator<Item = (Port, Type)>
Source§fn in_value_types(
&self,
node: Self::Node,
) -> impl Iterator<Item = (IncomingPort, Type)>
fn in_value_types( &self, node: Self::Node, ) -> impl Iterator<Item = (IncomingPort, Type)>
Source§fn out_value_types(
&self,
node: Self::Node,
) -> impl Iterator<Item = (OutgoingPort, Type)>
fn out_value_types( &self, node: Self::Node, ) -> impl Iterator<Item = (OutgoingPort, Type)>
Source§impl IntoIterator for PersistentHugr
impl IntoIterator for PersistentHugr
Source§impl Patch<PersistentHugr> for PersistentReplacement
impl Patch<PersistentHugr> for PersistentReplacement
Source§const UNCHANGED_ON_FAILURE: bool = true
const UNCHANGED_ON_FAILURE: bool = true
true
, Patch::apply
’s of this rewrite guarantee that they do not
mutate the Hugr when they return an Err. If false
, there is no
guarantee; the Hugr should be assumed invalid when Err is returned.Auto Trait Implementations§
impl Freeze for PersistentHugr
impl !RefUnwindSafe for PersistentHugr
impl !Send for PersistentHugr
impl !Sync for PersistentHugr
impl Unpin for PersistentHugr
impl !UnwindSafe for PersistentHugr
Blanket Implementations§
Source§impl<I> BidiIterator for I
impl<I> BidiIterator for I
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<H, Handle> RootCheckable<H, Handle> for H
impl<H, Handle> RootCheckable<H, Handle> for H
Source§fn try_into_checked(self) -> Result<RootChecked<H, Handle>, HugrError>
fn try_into_checked(self) -> Result<RootChecked<H, Handle>, HugrError>
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.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
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.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
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.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
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.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
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.