From 8724149a0472987d14190e0314aab9f4fdddcc84 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Wed, 3 Jun 2020 00:54:02 +0530 Subject: [PATCH] cargo fix + fmt --- src/api/search.rs | 8 ++++++-- src/graph.rs | 2 +- src/main.rs | 2 +- src/markdown.rs | 13 +++++++++---- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/api/search.rs b/src/api/search.rs index ea0eab3..c38a99b 100644 --- a/src/api/search.rs +++ b/src/api/search.rs @@ -35,8 +35,12 @@ impl PullRequest { &self.base.label } - pub fn number(&self) -> usize { self.number } - pub fn title(&self) -> &str { &self.title } + pub fn number(&self) -> usize { + self.number + } + pub fn title(&self) -> &str { + &self.title + } } #[derive(Deserialize, Debug)] diff --git a/src/graph.rs b/src/graph.rs index 3aff837..31b0a09 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1,6 +1,6 @@ +use petgraph::Graph; use std::collections::HashMap; use std::rc::Rc; -use petgraph::Graph; use crate::api::search::PullRequest; diff --git a/src/main.rs b/src/main.rs index 1d867fa..6b0123c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; -use std::rc::Rc; use std::env; use std::error::Error; use std::process; +use std::rc::Rc; use gh_stack::api; use gh_stack::graph; diff --git a/src/markdown.rs b/src/markdown.rs index 1b3ac34..bb23969 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -1,8 +1,8 @@ -use petgraph::{Direction,Graph}; -use std::rc::Rc; use petgraph::visit::Bfs; use petgraph::visit::EdgeRef; +use petgraph::{Direction, Graph}; use regex::Regex; +use std::rc::Rc; use crate::api::search::PullRequest; @@ -25,9 +25,14 @@ pub fn build_table(graph: Graph, usize>) -> String { while let Some(node) = bfs.next(&graph) { let parent = graph.edges_directed(node, Direction::Incoming).next(); let node: Rc = graph[node].clone(); - + let row = match parent { - Some(parent) => format!("|#{}|{}|#{}|\n", node.number(), node.title(), graph[parent.source().clone()].number()), + Some(parent) => format!( + "|#{}|{}|#{}|\n", + node.number(), + node.title(), + graph[parent.source().clone()].number() + ), None => format!("|#{}|{}|**N/A**|\n", node.number(), node.title()), };