mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-27 15:40:03 +08:00
fix clippy
This commit is contained in:
@@ -42,7 +42,7 @@ pub fn get_absolute_path(path: &str) -> Option<PathBuf> {
|
|||||||
|
|
||||||
pub fn read_file_content(file: &str) -> XResult<String> {
|
pub fn read_file_content(file: &str) -> XResult<String> {
|
||||||
match get_absolute_path(file) {
|
match get_absolute_path(file) {
|
||||||
None => return Err(new_box_ioerror(&format!("File not found: {}", file))),
|
None => Err(new_box_ioerror(&format!("File not found: {}", file))),
|
||||||
Some(p) => util_io::read_to_string(&mut fs::File::open(p)?),
|
Some(p) => util_io::read_to_string(&mut fs::File::open(p)?),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,14 +89,12 @@ fn walk_dir_with_depth_check<FError, FProcess, FFilter>(depth: &mut u32, dir: &P
|
|||||||
let sub_dir = path_buf.as_path();
|
let sub_dir = path_buf.as_path();
|
||||||
if sub_dir.is_file() {
|
if sub_dir.is_file() {
|
||||||
func_process_file(&sub_dir);
|
func_process_file(&sub_dir);
|
||||||
} else if sub_dir.is_dir() {
|
} else if sub_dir.is_dir() && func_filter_dir(&sub_dir) {
|
||||||
if func_filter_dir(&sub_dir) {
|
*depth += 1;
|
||||||
*depth += 1;
|
if let Err(err) = walk_dir_with_depth_check(depth, &sub_dir, func_walk_error, func_process_file, func_filter_dir) {
|
||||||
if let Err(err) = walk_dir_with_depth_check(depth, &sub_dir, func_walk_error, func_process_file, func_filter_dir) {
|
func_walk_error(&sub_dir, err);
|
||||||
func_walk_error(&sub_dir, err);
|
|
||||||
}
|
|
||||||
*depth -= 1;
|
|
||||||
}
|
}
|
||||||
|
*depth -= 1;
|
||||||
} // should process else ? not file, dir
|
} // should process else ? not file, dir
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use std::{
|
|||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref IS_ATTY: bool = is_atty();
|
pub static ref IS_ATTY: bool = is_atty();
|
||||||
static ref PRINT_MESSAGE_LOCK: Arc<Mutex<usize>> = Arc::new(Mutex::new(0));
|
static ref PRINT_MESSAGE_LOCK: Arc<Mutex<()>> = Arc::new(Mutex::new(()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum MessageType { INFO, OK, WARN, ERROR, DEBUG, }
|
pub enum MessageType { INFO, OK, WARN, ERROR, DEBUG, }
|
||||||
@@ -40,7 +40,7 @@ pub fn print_message_ex(color: Option<term::color::Color>, h: &str, message: &st
|
|||||||
let mut lock = PRINT_MESSAGE_LOCK.lock().unwrap();
|
let mut lock = PRINT_MESSAGE_LOCK.lock().unwrap();
|
||||||
print_color(color, true, h);
|
print_color(color, true, h);
|
||||||
println!(" {}", message);
|
println!(" {}", message);
|
||||||
*lock += 1;
|
*lock = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_message(mt: MessageType, message: &str) {
|
pub fn print_message(mt: MessageType, message: &str) {
|
||||||
|
|||||||
Reference in New Issue
Block a user