From d569693dab51d95e5e49be25435df2c4ba64ef37 Mon Sep 17 00:00:00 2001 From: eth-p <32112321+eth-p@users.noreply.github.com> Date: Tue, 15 May 2018 17:45:58 -0700 Subject: [PATCH] Formatted with newer cargo fmt. It should pass all the checks now. --- src/app.rs | 2 +- src/diff.rs | 3 ++- src/main.rs | 2 +- src/printer.rs | 13 ++++++++----- tests/tester.rs | 5 +---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/app.rs b/src/app.rs index 7f7b6b70..def53f07 100644 --- a/src/app.rs +++ b/src/app.rs @@ -59,7 +59,7 @@ impl App { .use_delimiter(true) .takes_value(true) .possible_values(&[ - "auto", "full", "plain", "changes", "header", "grid", "numbers" + "auto", "full", "plain", "changes", "header", "grid", "numbers", ]) .default_value("auto") .help("Additional info to display along with content"), diff --git a/src/diff.rs b/src/diff.rs index e6719a4e..ab315c91 100644 --- a/src/diff.rs +++ b/src/diff.rs @@ -23,7 +23,8 @@ pub fn get_git_diff(filename: &str) -> Option { diff_options.pathspec(pathspec); diff_options.context_lines(0); - let diff = repo.diff_index_to_workdir(None, Some(&mut diff_options)) + let diff = repo + .diff_index_to_workdir(None, Some(&mut diff_options)) .ok()?; let mut line_changes: LineChanges = HashMap::new(); diff --git a/src/main.rs b/src/main.rs index d5a907f0..833fa5d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,11 +19,11 @@ extern crate syntect; mod app; mod assets; +mod decorations; mod diff; mod printer; mod style; mod terminal; -mod decorations; use std::fs::{self, File}; use std::io::{self, BufRead, BufReader, Write}; diff --git a/src/printer.rs b/src/printer.rs index 19a97aa7..a51cc4dc 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -1,13 +1,13 @@ use app::Config; +use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration}; use diff::LineChanges; use errors::*; +use std::boxed::Box; use std::io::Write; use std::vec::Vec; -use std::boxed::Box; +use style::OutputWrap; use syntect::highlighting; use terminal::as_terminal_escaped; -use style::OutputWrap; -use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration}; use Colors; pub struct Printer<'a> { @@ -50,7 +50,9 @@ impl<'a> Printer<'a> { // Disable the panel if the terminal is too small (i.e. can't fit 5 characters with the // panel showing). - if config.term_width < (decorations.len() + decorations.iter().fold(0, |a, x| a + x.width())) + 5 { + if config.term_width + < (decorations.len() + decorations.iter().fold(0, |a, x| a + x.width())) + 5 + { decorations.clear(); panel_width = 0; } @@ -117,7 +119,8 @@ impl<'a> Printer<'a> { // Line decorations. if self.panel_width > 0 { - let decorations = self.decorations + let decorations = self + .decorations .iter() .map(|ref d| d.generate(line_number, false, self)) .collect::>(); diff --git a/tests/tester.rs b/tests/tester.rs index 21a7829d..9865cbc1 100644 --- a/tests/tester.rs +++ b/tests/tester.rs @@ -29,10 +29,7 @@ impl BatTester { pub fn test_snapshot(&self, style: &str) { let output = Command::new(&self.exe) - .args(&[ - "tests/snapshots/sample.rs", - &format!("--style={}", style), - ]) + .args(&["tests/snapshots/sample.rs", &format!("--style={}", style)]) .output() .expect("bat failed"); // have to do the replace because the filename in the header changes based on the current working directory