pub struct PortGraph { /* private fields */ }Expand description
An unlabelled port graph.
A port graph consists of a collection of nodes identified by a NodeIndex.
Each node has an ordered sequence of input and output ports, identified by a PortIndex that is unique within the graph.
To optimize for the most common use case, the number of input and output ports of a node must be specified when the node is created.
When a node and its associated ports are removed their indices will be reused on a best effort basis
when a new node is added.
The indices of unaffected nodes and ports remain stable.
PortGraph::compact_nodes and PortGraph::compact_ports to eliminate fragmentation in the index space.
Implementations§
source§impl PortGraph
impl PortGraph
sourcepub fn with_capacity(nodes: usize, ports: usize) -> Self
pub fn with_capacity(nodes: usize, ports: usize) -> Self
Create a new empty PortGraph with preallocated capacity.
sourcepub fn add_node(&mut self, incoming: usize, outgoing: usize) -> NodeIndex
pub fn add_node(&mut self, incoming: usize, outgoing: usize) -> NodeIndex
Adds a node to the portgraph with a given number of input and output ports.
Panics
Panics if the total number of ports exceeds u16::MAX.
Example
let mut g = PortGraph::new();
let node = g.add_node(4, 3);
assert_eq!(g.inputs(node).count(), 4);
assert_eq!(g.outputs(node).count(), 3);
assert!(g.contains_node(node));sourcepub fn remove_node(&mut self, node: NodeIndex)
pub fn remove_node(&mut self, node: NodeIndex)
Remove a node from the port graph. All ports of the node will be unlinked and removed as well. Does nothing if the node does not exist.
Example
let mut g = PortGraph::new();
let node0 = g.add_node(1, 1);
let node1 = g.add_node(1, 1);
g.link_ports(g.outputs(node0).nth(0).unwrap(), g.inputs(node1).nth(0).unwrap());
g.link_ports(g.outputs(node1).nth(0).unwrap(), g.inputs(node0).nth(0).unwrap());
g.remove_node(node0);
assert!(!g.contains_node(node0));
assert!(g.port_link(g.outputs(node1).nth(0).unwrap()).is_none());
assert!(g.port_link(g.inputs(node1).nth(0).unwrap()).is_none());sourcepub fn link_ports(
&mut self,
port_a: PortIndex,
port_b: PortIndex
) -> Result<(), LinkError>
pub fn link_ports( &mut self, port_a: PortIndex, port_b: PortIndex ) -> Result<(), LinkError>
Link an output and an input port.
Example
let mut g = PortGraph::new();
let node0 = g.add_node(0, 1);
let node1 = g.add_node(1, 0);
let node0_output = g.output(node0, 0).unwrap();
let node1_input = g.input(node1, 0).unwrap();
g.link_ports(node0_output, node1_input).unwrap();
assert_eq!(g.port_link(node0_output), Some(node1_input));
assert_eq!(g.port_link(node1_input), Some(node0_output));Errors
- If
port_aorport_bdoes not exist. - If
port_aandport_bhave the same direction. - If
port_aorport_bis already linked.
sourcepub fn unlink_port(&mut self, port: PortIndex) -> Option<PortIndex>
pub fn unlink_port(&mut self, port: PortIndex) -> Option<PortIndex>
Unlinks the port and returns the port it was linked to. Returns None
when the port was not linked.
sourcepub fn get_connections(
&self,
from: NodeIndex,
to: NodeIndex
) -> NodeConnections<'_> ⓘ
pub fn get_connections( &self, from: NodeIndex, to: NodeIndex ) -> NodeConnections<'_> ⓘ
Returns an iterator over every pair of matching ports connecting from
with to.
Example
let mut g = PortGraph::new();
let a = g.add_node(0, 2);
let b = g.add_node(2, 0);
g.link_nodes(a, 0, b, 0).unwrap();
g.link_nodes(a, 1, b, 1).unwrap();
let mut connections = g.get_connections(a, b);
assert_eq!(connections.next(), Some((g.output(a,0).unwrap(), g.input(b,0).unwrap())));
assert_eq!(connections.next(), Some((g.output(a,1).unwrap(), g.input(b,1).unwrap())));
assert_eq!(connections.next(), None);sourcepub fn get_connection(
&self,
from: NodeIndex,
to: NodeIndex
) -> Option<(PortIndex, PortIndex)>
pub fn get_connection( &self, from: NodeIndex, to: NodeIndex ) -> Option<(PortIndex, PortIndex)>
Checks whether there is a directed link between the two nodes and returns the first matching pair of ports.
Example
let mut g = PortGraph::new();
let a = g.add_node(0, 2);
let b = g.add_node(2, 0);
g.link_nodes(a, 0, b, 0).unwrap();
g.link_nodes(a, 1, b, 1).unwrap();
assert_eq!(g.get_connection(a, b), Some((g.output(a,0).unwrap(), g.input(b,0).unwrap())));sourcepub fn connected(&self, from: NodeIndex, to: NodeIndex) -> bool
pub fn connected(&self, from: NodeIndex, to: NodeIndex) -> bool
Checks whether there is a directed link between the two nodes.
Example
let mut g = PortGraph::new();
let a = g.add_node(0, 2);
let b = g.add_node(2, 0);
g.link_nodes(a, 0, b, 0).unwrap();
assert!(g.connected(a, b));sourcepub fn link_nodes(
&mut self,
from: NodeIndex,
from_output: usize,
to: NodeIndex,
to_input: usize
) -> Result<(PortIndex, PortIndex), LinkError>
pub fn link_nodes( &mut self, from: NodeIndex, from_output: usize, to: NodeIndex, to_input: usize ) -> Result<(PortIndex, PortIndex), LinkError>
Links two nodes at an input and output port offsets.
Errors
- If the ports and nodes do not exist.
- If the ports are already linked.
sourcepub fn link_offsets(
&mut self,
node_a: NodeIndex,
offset_a: PortOffset,
node_b: NodeIndex,
offset_b: PortOffset
) -> Result<(PortIndex, PortIndex), LinkError>
pub fn link_offsets( &mut self, node_a: NodeIndex, offset_a: PortOffset, node_b: NodeIndex, offset_b: PortOffset ) -> Result<(PortIndex, PortIndex), LinkError>
Links two nodes at an input and output port offsets.
Errors
- If the ports and nodes do not exist.
- If the ports have the same direction.
- If the ports are already linked.
sourcepub fn port_direction(&self, port: PortIndex) -> Option<Direction>
pub fn port_direction(&self, port: PortIndex) -> Option<Direction>
Returns the direction of the port.
sourcepub fn port_node(&self, port: PortIndex) -> Option<NodeIndex>
pub fn port_node(&self, port: PortIndex) -> Option<NodeIndex>
Returns the node that the port belongs to.
sourcepub fn port_offset(&self, port: PortIndex) -> Option<PortOffset>
pub fn port_offset(&self, port: PortIndex) -> Option<PortOffset>
Returns the index of a port within its node’s port list.
sourcepub fn port_index(
&self,
node: NodeIndex,
offset: PortOffset
) -> Option<PortIndex>
pub fn port_index( &self, node: NodeIndex, offset: PortOffset ) -> Option<PortIndex>
Returns the port index for a given node, direction, and offset.
sourcepub fn port_link(&self, port: PortIndex) -> Option<PortIndex>
pub fn port_link(&self, port: PortIndex) -> Option<PortIndex>
Returns the port that the given port is linked to.
sourcepub fn ports(&self, node: NodeIndex, direction: Direction) -> NodePorts ⓘ
pub fn ports(&self, node: NodeIndex, direction: Direction) -> NodePorts ⓘ
Iterates over all the ports of the node in the given direction.
sourcepub fn all_ports(&self, node: NodeIndex) -> NodePorts ⓘ
pub fn all_ports(&self, node: NodeIndex) -> NodePorts ⓘ
Iterates over the input and output ports of the node in sequence.
sourcepub fn input(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>
pub fn input(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>
Returns the input port at the given offset in the node.
Shorthand for PortGraph::port_index.
sourcepub fn output(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>
pub fn output(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>
Returns the output port at the given offset in the node.
Shorthand for PortGraph::ports.
sourcepub fn inputs(&self, node: NodeIndex) -> NodePorts ⓘ
pub fn inputs(&self, node: NodeIndex) -> NodePorts ⓘ
Iterates over all the input ports of the node.
Shorthand for PortGraph::ports.
sourcepub fn outputs(&self, node: NodeIndex) -> NodePorts ⓘ
pub fn outputs(&self, node: NodeIndex) -> NodePorts ⓘ
Iterates over all the output ports of the node.
Shorthand for PortGraph::ports.
sourcepub fn num_inputs(&self, node: NodeIndex) -> usize
pub fn num_inputs(&self, node: NodeIndex) -> usize
Returns the number of input ports of the node.
Shorthand for PortGraph::num_ports.
sourcepub fn num_outputs(&self, node: NodeIndex) -> usize
pub fn num_outputs(&self, node: NodeIndex) -> usize
Returns the number of output ports of the node.
Shorthand for PortGraph::num_ports.
sourcepub fn num_ports(&self, node: NodeIndex, direction: Direction) -> usize
pub fn num_ports(&self, node: NodeIndex, direction: Direction) -> usize
Returns the number of ports of the node in the given direction.
sourcepub fn port_offsets(
&self,
node: NodeIndex,
direction: Direction
) -> NodePortOffsets ⓘ
pub fn port_offsets( &self, node: NodeIndex, direction: Direction ) -> NodePortOffsets ⓘ
Iterates over all the port offsets of the node in the given direction.
Example
let mut graph = PortGraph::new();
let node = graph.add_node(0, 2);
assert!(graph.links(node, Direction::Incoming).eq([]));
assert!(graph.port_offsets(node, Direction::Outgoing).eq([PortOffset::new_outgoing(0), PortOffset::new_outgoing(1)]));sourcepub fn input_offsets(&self, node: NodeIndex) -> NodePortOffsets ⓘ
pub fn input_offsets(&self, node: NodeIndex) -> NodePortOffsets ⓘ
Iterates over all the input port offsets of the node.
Shorthand for PortGraph::port_offsets.
sourcepub fn output_offsets(&self, node: NodeIndex) -> NodePortOffsets ⓘ
pub fn output_offsets(&self, node: NodeIndex) -> NodePortOffsets ⓘ
Iterates over all the output port offsets of the node.
Shorthand for PortGraph::port_offsets.
sourcepub fn all_port_offsets(&self, node: NodeIndex) -> NodePortOffsets ⓘ
pub fn all_port_offsets(&self, node: NodeIndex) -> NodePortOffsets ⓘ
Iterates over the input and output port offsets of the node in sequence.
sourcepub fn links(&self, node: NodeIndex, direction: Direction) -> NodeLinks<'_> ⓘ
pub fn links(&self, node: NodeIndex, direction: Direction) -> NodeLinks<'_> ⓘ
Iterates over the links of the node in the given direction. When the
corresponding node port is linked to another one, the Option contains
the index of the other port.
Examples
let mut graph = PortGraph::new();
let node_a = graph.add_node(0, 2);
let node_b = graph.add_node(1, 0);
let port_a = graph.outputs(node_a).next().unwrap();
let port_b = graph.inputs(node_b).next().unwrap();
graph.link_ports(port_a, port_b).unwrap();
assert!(graph.links(node_a, Direction::Outgoing).eq([Some(port_b), None]));
assert!(graph.links(node_b, Direction::Incoming).eq([Some(port_a)]));sourcepub fn input_links(&self, node: NodeIndex) -> NodeLinks<'_> ⓘ
pub fn input_links(&self, node: NodeIndex) -> NodeLinks<'_> ⓘ
Iterates over the input links of the node. Shorthand for PortGraph::links.
sourcepub fn output_links(&self, node: NodeIndex) -> NodeLinks<'_> ⓘ
pub fn output_links(&self, node: NodeIndex) -> NodeLinks<'_> ⓘ
Iterates over the output links of the node. Shorthand for PortGraph::links.
sourcepub fn all_links(&self, node: NodeIndex) -> NodeLinks<'_> ⓘ
pub fn all_links(&self, node: NodeIndex) -> NodeLinks<'_> ⓘ
Iterates over the input and output links of the node in sequence.
sourcepub fn neighbours(
&self,
node: NodeIndex,
direction: Direction
) -> Neighbours<'_> ⓘ
pub fn neighbours( &self, node: NodeIndex, direction: Direction ) -> Neighbours<'_> ⓘ
Iterates over neighbour nodes in the given direction.
May contain duplicates if the graph has multiple links between nodes.
Examples
let mut graph = PortGraph::new();
let a = graph.add_node(0, 1);
let b = graph.add_node(2, 1);
graph.link_nodes(a, 0, b, 0).unwrap();
graph.link_nodes(b, 0, b, 1).unwrap();
assert!(graph.neighbours(a, Direction::Outgoing).eq([b]));
assert!(graph.neighbours(b, Direction::Incoming).eq([a,b]));sourcepub fn input_neighbours(&self, node: NodeIndex) -> Neighbours<'_> ⓘ
pub fn input_neighbours(&self, node: NodeIndex) -> Neighbours<'_> ⓘ
Iterates over the input neighbours of the node. Shorthand for PortGraph::neighbours.
sourcepub fn output_neighbours(&self, node: NodeIndex) -> Neighbours<'_> ⓘ
pub fn output_neighbours(&self, node: NodeIndex) -> Neighbours<'_> ⓘ
Iterates over the output neighbours of the node. Shorthand for PortGraph::neighbours.
sourcepub fn all_neighbours(&self, node: NodeIndex) -> Neighbours<'_> ⓘ
pub fn all_neighbours(&self, node: NodeIndex) -> Neighbours<'_> ⓘ
Iterates over the input and output neighbours of the node in sequence.
sourcepub fn contains_node(&self, node: NodeIndex) -> bool
pub fn contains_node(&self, node: NodeIndex) -> bool
Returns whether the port graph contains the node.
sourcepub fn contains_port(&self, port: PortIndex) -> bool
pub fn contains_port(&self, port: PortIndex) -> bool
Returns whether the port graph contains the port.
sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Returns the number of nodes in the port graph.
sourcepub fn port_count(&self) -> usize
pub fn port_count(&self) -> usize
Returns the number of ports in the port graph.
sourcepub fn link_count(&self) -> usize
pub fn link_count(&self) -> usize
Returns the number of links between ports.
sourcepub fn nodes_iter(&self) -> Nodes<'_> ⓘ
pub fn nodes_iter(&self) -> Nodes<'_> ⓘ
Iterates over the nodes in the port graph.
sourcepub fn ports_iter(&self) -> Ports<'_> ⓘ
pub fn ports_iter(&self) -> Ports<'_> ⓘ
Iterates over the ports in the port graph.
sourcepub fn node_capacity(&self) -> usize
pub fn node_capacity(&self) -> usize
Returns the capacity of the underlying buffer for nodes.
sourcepub fn port_capacity(&self) -> usize
pub fn port_capacity(&self) -> usize
Returns the capacity of the underlying buffer for ports.
sourcepub fn node_port_capacity(&self, node: NodeIndex) -> usize
pub fn node_port_capacity(&self, node: NodeIndex) -> usize
Returns the allocated port capacity for a specific node.
Changes to the number of ports of the node will not reallocate until the number of ports exceeds this capacity.
sourcepub fn reserve(&mut self, nodes: usize, ports: usize)
pub fn reserve(&mut self, nodes: usize, ports: usize)
Reserves enough capacity to insert at least the given number of additional nodes and ports.
This method does not take into account the length of the free list and might overallocate speculatively.
sourcepub fn set_num_ports<F>(
&mut self,
node: NodeIndex,
incoming: usize,
outgoing: usize,
rekey: F
)where
F: FnMut(PortIndex, PortOperation),
pub fn set_num_ports<F>( &mut self, node: NodeIndex, incoming: usize, outgoing: usize, rekey: F )where F: FnMut(PortIndex, PortOperation),
Changes the number of ports of the node to the given incoming and outgoing counts.
Invalidates the indices of the node’s ports. If the number of incoming or outgoing ports is reduced, the ports are removed from the end of the port list.
Every time a port is moved, the rekey function will be called with its old and new index.
If the port is removed, the new index will be None.
This operation is O(n) where n is the number of ports of the node.
sourcepub fn compact_nodes<F>(&mut self, rekey: F)where
F: FnMut(NodeIndex, NodeIndex),
pub fn compact_nodes<F>(&mut self, rekey: F)where F: FnMut(NodeIndex, NodeIndex),
Compacts the storage of nodes in the portgraph so that all nodes are stored consecutively.
Every time a node is moved, the rekey function will be called with its old and new index.
sourcepub fn compact_ports<F>(&mut self, rekey: F)where
F: FnMut(PortIndex, PortIndex),
pub fn compact_ports<F>(&mut self, rekey: F)where F: FnMut(PortIndex, PortIndex),
Compacts the storage of ports in the portgraph so that all ports are stored consecutively.
Shrinks the port capacity of every node to match the number of ports it contains.
Every time a port is moved, the rekey function will be called with is old and new index.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the underlying buffers to the fit the data.
This does not move nodes or ports, which might prevent freeing up more capacity.
To shrink the buffers as much as possible, call PortGraph::compact_nodes and
PortGraph::compact_ports first.
source§impl PortGraph
impl PortGraph
sourcepub fn apply_rewrite(&mut self, rewrite: Rewrite) -> Result<(), RewriteError>
pub fn apply_rewrite(&mut self, rewrite: Rewrite) -> Result<(), RewriteError>
Applies a rewrite to the graph.
sourcepub fn apply_weighted_rewrite<N: Clone, P: Clone>(
&mut self,
rewrite: WeightedRewrite<N, P>,
weights: &mut Weights<N, P>
) -> Result<(), RewriteError>
pub fn apply_weighted_rewrite<N: Clone, P: Clone>( &mut self, rewrite: WeightedRewrite<N, P>, weights: &mut Weights<N, P> ) -> Result<(), RewriteError>
Applies a rewrite to the graph and associated weights.
sourcepub fn apply_rewrite_with_callbacks(
&mut self,
rewrite: Rewrite,
node_removed: impl FnMut(NodeIndex),
port_removed: impl FnMut(PortIndex),
node_inserted: impl FnMut(NodeIndex, NodeIndex),
port_inserted: impl FnMut(PortIndex, PortIndex),
ports_connected: impl FnMut(PortIndex, PortIndex)
) -> Result<(), RewriteError>
pub fn apply_rewrite_with_callbacks( &mut self, rewrite: Rewrite, node_removed: impl FnMut(NodeIndex), port_removed: impl FnMut(PortIndex), node_inserted: impl FnMut(NodeIndex, NodeIndex), port_inserted: impl FnMut(PortIndex, PortIndex), ports_connected: impl FnMut(PortIndex, PortIndex) ) -> Result<(), RewriteError>
Applies a rewrite to the graph, calling the provided callbacks as the rewrite is applied.
Parameters
rewrite: The rewrite to apply.node_removed: A callback that is called with the index of each node that is removed.port_removed: A callback that is called with the index of each port that is removed.node_inserted: A callback that is called with the old node index in the rewrite’s OpenGraph, and the new node index in the graph.port_inserted: A callback that is called with the old port index in the rewrite’s OpenGraph, and the new port index in the graph.ports_connected: A callback that is called when two ports are connected.
Trait Implementations§
source§impl PartialEq<PortGraph> for PortGraph
impl PartialEq<PortGraph> for PortGraph
impl StructuralPartialEq for PortGraph
Auto Trait Implementations§
impl RefUnwindSafe for PortGraph
impl Send for PortGraph
impl Sync for PortGraph
impl Unpin for PortGraph
impl UnwindSafe for PortGraph
Blanket Implementations§
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
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§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.§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.§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.§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.§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.§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.§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.§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.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§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 more§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 more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self, then passes self.as_mut() into the pipe
function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target of a value. Read more§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.§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.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut() only in debug builds, and is erased in release
builds.