Run rustfmt on src/librustc_data_structures/graph/mod.rs.

This commit is contained in:
Corey Farwell 2018-03-03 10:24:29 -05:00
parent 3e60d996a0
commit 08a0182536

View file

@ -210,16 +210,16 @@ impl<N: Debug, E: Debug> Graph<N, E> {
.map(|(idx, e)| (EdgeIndex(idx), e))
}
pub fn each_node<'a>(&'a self, mut f: impl FnMut(NodeIndex, &'a Node<N>) -> bool) -> bool
{
pub fn each_node<'a>(&'a self, mut f: impl FnMut(NodeIndex, &'a Node<N>) -> bool) -> bool {
//! Iterates over all edges defined in the graph.
self.enumerated_nodes().all(|(node_idx, node)| f(node_idx, node))
self.enumerated_nodes()
.all(|(node_idx, node)| f(node_idx, node))
}
pub fn each_edge<'a>(&'a self, mut f: impl FnMut(EdgeIndex, &'a Edge<E>) -> bool) -> bool
{
pub fn each_edge<'a>(&'a self, mut f: impl FnMut(EdgeIndex, &'a Edge<E>) -> bool) -> bool {
//! Iterates over all edges defined in the graph
self.enumerated_edges().all(|(edge_idx, edge)| f(edge_idx, edge))
self.enumerated_edges()
.all(|(edge_idx, edge)| f(edge_idx, edge))
}
pub fn outgoing_edges(&self, source: NodeIndex) -> AdjacentEdges<N, E> {
@ -253,18 +253,19 @@ impl<N: Debug, E: Debug> Graph<N, E> {
self.incoming_edges(target).sources()
}
pub fn depth_traverse<'a>(&'a self,
start: NodeIndex,
direction: Direction)
-> DepthFirstTraversal<'a, N, E> {
pub fn depth_traverse<'a>(
&'a self,
start: NodeIndex,
direction: Direction,
) -> DepthFirstTraversal<'a, N, E> {
DepthFirstTraversal::with_start_node(self, start, direction)
}
pub fn nodes_in_postorder<'a>(&'a self,
direction: Direction,
entry_node: NodeIndex)
-> Vec<NodeIndex>
{
pub fn nodes_in_postorder<'a>(
&'a self,
direction: Direction,
entry_node: NodeIndex,
) -> Vec<NodeIndex> {
let mut visited = BitVector::new(self.len_nodes());
let mut stack = vec![];
let mut result = Vec::with_capacity(self.len_nodes());
@ -274,7 +275,8 @@ impl<N: Debug, E: Debug> Graph<N, E> {
}
};
for node in Some(entry_node).into_iter()
for node in Some(entry_node)
.into_iter()
.chain(self.enumerated_nodes().map(|(node, _)| node))
{
push_node(&mut stack, node);
@ -300,8 +302,9 @@ impl<N: Debug, E: Debug> Graph<N, E> {
// # Iterators
pub struct AdjacentEdges<'g, N, E>
where N: 'g,
E: 'g
where
N: 'g,
E: 'g,
{
graph: &'g Graph<N, E>,
direction: Direction,
@ -334,8 +337,9 @@ impl<'g, N: Debug, E: Debug> Iterator for AdjacentEdges<'g, N, E> {
}
pub struct DepthFirstTraversal<'g, N, E>
where N: 'g,
E: 'g
where
N: 'g,
E: 'g,
{
graph: &'g Graph<N, E>,
stack: Vec<NodeIndex>,
@ -344,10 +348,11 @@ pub struct DepthFirstTraversal<'g, N, E>
}
impl<'g, N: Debug, E: Debug> DepthFirstTraversal<'g, N, E> {
pub fn with_start_node(graph: &'g Graph<N, E>,
start_node: NodeIndex,
direction: Direction)
-> Self {
pub fn with_start_node(
graph: &'g Graph<N, E>,
start_node: NodeIndex,
direction: Direction,
) -> Self {
let mut visited = BitVector::new(graph.len_nodes());
visited.insert(start_node.node_id());
DepthFirstTraversal {