Skip to content

Commit

Permalink
Run rustfmt on src/librustc_data_structures/graph/mod.rs.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Mar 8, 2018
1 parent 3e60d99 commit 08a0182
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions src/librustc_data_structures/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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());
Expand All @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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>,
Expand All @@ -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 {
Expand Down

0 comments on commit 08a0182

Please sign in to comment.