Run 'cargo fmt'

This commit is contained in:
sharkdp 2020-02-28 10:27:06 +01:00
parent 4ac3161c19
commit ca066bf7cd
6 changed files with 19 additions and 11 deletions

View File

@ -9,11 +9,11 @@ mod clap_app;
mod config;
use std::collections::HashSet;
use std::ffi::OsStr;
use std::io;
use std::io::Write;
use std::path::Path;
use std::process;
use std::ffi::OsStr;
use ansi_term::Colour::Green;
use ansi_term::Style;

View File

@ -1,7 +1,7 @@
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs;
use std::path::Path;
use std::ffi::OsStr;
use git2::{DiffOptions, IntoCString, Repository};

View File

@ -1,6 +1,6 @@
use std::ffi::OsStr;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::ffi::OsStr;
use content_inspector::{self, ContentType};
@ -64,7 +64,8 @@ impl<'a> InputFile<'a> {
match self {
InputFile::StdIn => Ok(InputFileReader::new(stdin.lock())),
InputFile::Ordinary(filename) => {
let file = File::open(filename).map_err(|e| format!("'{}': {}", filename.to_string_lossy(), e))?;
let file = File::open(filename)
.map_err(|e| format!("'{}': {}", filename.to_string_lossy(), e))?;
if file.metadata()?.is_dir() {
return Err(format!("'{}' is a directory.", filename.to_string_lossy()).into());

View File

@ -35,13 +35,16 @@ impl LineRange {
new_range.lower = line_numbers[0].parse()?;
new_range.upper = new_range.lower;
Ok(new_range)
},
}
2 => {
new_range.lower = line_numbers[0].parse()?;
new_range.upper = line_numbers[1].parse()?;
Ok(new_range)
},
_ => Err("Line range contained more than one ':' character. Expected format: 'N' or 'N:M'".into()),
}
_ => Err(
"Line range contained more than one ':' character. Expected format: 'N' or 'N:M'"
.into(),
),
}
}

View File

@ -1,6 +1,6 @@
use std::borrow::Cow;
use std::io::Write;
use std::vec::Vec;
use std::borrow::Cow;
use ansi_term::Colour::{Fixed, Green, Red, Yellow};
use ansi_term::Style;
@ -228,7 +228,9 @@ impl<'a> Printer for InteractivePrinter<'a> {
if !self.config.output_components.header() {
if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
let input = match file {
InputFile::Ordinary(filename) => format!("file '{}'", filename.to_string_lossy()),
InputFile::Ordinary(filename) => {
format!("file '{}'", filename.to_string_lossy())
}
_ => "STDIN".into(),
};

View File

@ -494,7 +494,8 @@ fn unicode_wrap() {
.arg("--terminal-width=40")
.assert()
.success()
.stdout(" 1 ビタミンA ビタミンD ビタミンE ビ
.stdout(
" 1 ビタミンA ビタミンD ビタミンE ビ
K B1 B2
B6
B12
@ -522,7 +523,8 @@ fn unicode_wrap() {
дерланды Австрия Польша Португалия
Румыния Словения Словакия Финляндия
Швеция Великобритания
");
",
);
}
#[test]