Struct PersistentHugr

Source
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

Source

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.

Source

pub fn from_commit(commit: Commit) -> Self

Create a PersistentHugr from a single commit and its ancestors.

Source

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.

Source

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.

Source

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:

Source

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.

Source

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.

Source

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.

Source

pub fn as_state_space(&self) -> &CommitStateSpace

Get a reference to the underlying state space of self.

Source

pub fn into_state_space(self) -> CommitStateSpace

Convert self into its underlying CommitStateSpace.

Source

pub fn contains(&self, commit: &Commit) -> bool

Check if commit is in the PersistentHugr.

Source

pub fn contains_id(&self, commit_id: CommitId) -> bool

Check if commit_id is in the PersistentHugr.

Source

pub fn base(&self) -> CommitId

Get the base commit ID.

Source

pub fn base_hugr(&self) -> &Hugr

Get the base Hugr.

Source

pub fn base_commit(&self) -> &Commit

Get the base commit.

Source

pub fn get_commit(&self, commit_id: CommitId) -> &Commit

Get the commit with ID commit_id.

Source

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.

Source

pub fn all_commit_ids(&self) -> impl Iterator<Item = CommitId> + Clone + '_

Get an iterator over all commit IDs in the persistent HUGR.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> PersistentHugr

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 PersistentHugr

Source§

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

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

impl HugrInternals for PersistentHugr

Source§

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

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

type Node = PatchNode

The type of nodes in the Hugr.
Source§

type RegionPortgraphNodes = HashMap<PatchNode, Node>

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 HugrView for PersistentHugr

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: Self::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 = Self::Node> + Clone

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

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

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

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

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

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

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

fn node_connections( &self, node: Self::Node, other: Self::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: Self::Node, dir: Direction, ) -> impl Iterator<Item = Self::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: Self::Node, ) -> impl Iterator<Item = Self::Node> + Clone

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

fn mermaid_string(&self) -> String

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

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

Return the mermaid representation of the underlying hierarchical graph. 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, parent: Self::Node, ) -> (Hugr, impl ExtractionResult<Self::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 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 IntoIterator for PersistentHugr

Source§

type Item = Commit

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Commit>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl Patch<PersistentHugr> for PersistentReplacement

Source§

const UNCHANGED_ON_FAILURE: bool = true

If 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.
Source§

type Outcome = ()

The type returned on successful application of the rewrite.
Source§

fn apply(self, h: &mut PersistentHugr) -> Result<Self::Outcome, Self::Error>

Mutate the specified Hugr, or fail with an error. Read more

Auto Trait Implementations§

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<I> BidiIterator for I

Source§

fn bidi(self, cond: bool) -> Bidi<Self::IntoIter>

Conditionally reverses the direction of iteration. 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> 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, 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.