From 89f45cc354b60eeb4b21ffc27c301cacfcf9a11b Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sat, 19 Sep 2020 20:00:54 +0800 Subject: [PATCH] style: code style format --- src/util_cmd.rs | 5 +---- src/util_file.rs | 16 ++-------------- src/util_io.rs | 2 +- src/util_msg.rs | 10 +++------- src/util_net.rs | 10 +++++----- 5 files changed, 12 insertions(+), 31 deletions(-) diff --git a/src/util_cmd.rs b/src/util_cmd.rs index 11864f5..2beac6a 100644 --- a/src/util_cmd.rs +++ b/src/util_cmd.rs @@ -1,7 +1,4 @@ -use std::{ - io::{ self, Error, ErrorKind }, - process::Command, -}; +use std::{ io::{ self, Error, ErrorKind }, process::Command }; pub fn run_command_and_wait(cmd: &mut Command) -> io::Result<()> { cmd.spawn()?.wait()?; diff --git a/src/util_file.rs b/src/util_file.rs index 76560c0..76bc7f2 100644 --- a/src/util_file.rs +++ b/src/util_file.rs @@ -1,17 +1,5 @@ -use std::{ - env, - fs::{ self, File }, - io::{ Lines, BufReader }, - path::{ Path, PathBuf }, -}; -use crate::{ - iff, - util_os, - util_io, - util_msg, - new_box_ioerror, - XResult, -}; +use std::{ env, fs::{ self, File }, io::{ Lines, BufReader }, path::{ Path, PathBuf } }; +use crate::{ iff, util_os, util_io, util_msg, new_box_ioerror, XResult }; pub struct JoinFilesReader { files: Vec, diff --git a/src/util_io.rs b/src/util_io.rs index 365b9cb..59563a6 100644 --- a/src/util_io.rs +++ b/src/util_io.rs @@ -4,7 +4,7 @@ use std::{ time::{ SystemTime, Duration }, }; -use super::{ XResult, new_box_ioerror, }; +use super::{ XResult, new_box_ioerror }; use super::util_size::get_display_size; use super::util_msg::print_lastline; use super::util_file::resolve_file_path; diff --git a/src/util_msg.rs b/src/util_msg.rs index f98a2e3..dc84aca 100644 --- a/src/util_msg.rs +++ b/src/util_msg.rs @@ -1,8 +1,4 @@ -use std::{ - env, - io::{ self, Write }, - sync::{ Arc, Mutex }, -}; +use std::{ env, io::{ self, Write }, sync::{ Arc, Mutex } }; lazy_static! { pub static ref IS_ATTY: bool = is_atty(); @@ -11,7 +7,7 @@ lazy_static! { } #[derive(Clone, Copy)] -pub enum MessageType { DEBUG, INFO, OK, WARN, ERROR, } +pub enum MessageType { DEBUG, INFO, OK, WARN, ERROR } impl MessageType { pub fn get_u8_value(&self) -> u8 { @@ -30,7 +26,7 @@ pub fn get_logger_level() -> MessageType { match logger_level.trim().to_lowercase().as_str() { "debug" | "*" => MessageType::DEBUG, "info" | "?" => MessageType::INFO, - "ok" => MessageType::OK, + "ok" | "#" => MessageType::OK, "warn" | "!" => MessageType::WARN, "error" | "^" => MessageType::ERROR, _ => { diff --git a/src/util_net.rs b/src/util_net.rs index f6e715d..2b033c2 100644 --- a/src/util_net.rs +++ b/src/util_net.rs @@ -1,4 +1,4 @@ -use std::fmt::{ Display, Formatter }; +use std::fmt::{ self, Display, Formatter }; use std::result::Result; use std::net::SocketAddr; use crate::XResult; @@ -29,7 +29,7 @@ impl IpAddress { } impl Display for IpAddress { - fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> { write!(f, "{}", self.to_address()) } } @@ -83,7 +83,7 @@ impl IpAddressMask { } impl Display for IpAddressMask { - fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> { write!(f, "{}", self.to_address()) } } @@ -118,7 +118,7 @@ impl IpAddressMaskGroup { } impl Display for IpAddressMaskGroup { - fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> { write!(f, "[{}]", self.ip_address_mask_group.iter().map(|i| format!("{}", i)).collect::>().join(", ")) } } @@ -152,7 +152,7 @@ impl IpAddressAndPort { } impl Display for IpAddressAndPort { - fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> { write!(f, "{}:{}", self.ip, self.port) } }