mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-29 16:40:05 +08:00
fix clippy
This commit is contained in:
@@ -82,11 +82,8 @@ fn walk_dir_with_depth_check<FError, FProcess, FFilter>(depth: &mut u32, dir: &P
|
|||||||
} else if sub_dir.is_dir() {
|
} else if sub_dir.is_dir() {
|
||||||
if func_filter_dir(&sub_dir) {
|
if func_filter_dir(&sub_dir) {
|
||||||
*depth += 1;
|
*depth += 1;
|
||||||
match 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) {
|
||||||
Err(err) => {
|
func_walk_error(&sub_dir, err);
|
||||||
func_walk_error(&sub_dir, err);
|
|
||||||
},
|
|
||||||
Ok(_) => (),
|
|
||||||
}
|
}
|
||||||
*depth -= 1;
|
*depth -= 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,20 +15,18 @@ pub fn is_atty() -> bool{
|
|||||||
|
|
||||||
pub fn print_color(color: Option<term::color::Color>, is_bold: bool, m: &str) {
|
pub fn print_color(color: Option<term::color::Color>, is_bold: bool, m: &str) {
|
||||||
let mut t = term::stdout().unwrap();
|
let mut t = term::stdout().unwrap();
|
||||||
match *IS_ATTY {
|
if *IS_ATTY {
|
||||||
true => {
|
if let Some(c) = color {
|
||||||
match color {
|
t.fg(c).unwrap();
|
||||||
Some(c) => t.fg(c).unwrap(),
|
}
|
||||||
None => (),
|
if is_bold {
|
||||||
}
|
t.attr(term::Attr::Bold).unwrap();
|
||||||
if is_bold {
|
}
|
||||||
t.attr(term::Attr::Bold).unwrap();
|
write!(t, "{}", m).unwrap();
|
||||||
}
|
t.reset().unwrap();
|
||||||
write!(t, "{}", m).unwrap();
|
} else {
|
||||||
t.reset().unwrap();
|
write!(t, "{}", m).unwrap();
|
||||||
},
|
}
|
||||||
false => write!(t, "{}", m).unwrap(),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_color_and_flush(color: Option<term::color::Color>, is_bold: bool, m: &str) {
|
pub fn print_color_and_flush(color: Option<term::color::Color>, is_bold: bool, m: &str) {
|
||||||
|
|||||||
@@ -1,18 +1,10 @@
|
|||||||
|
|
||||||
pub fn is_macos() -> bool {
|
pub fn is_macos() -> bool {
|
||||||
if cfg!(target_os = "macos") {
|
cfg!(target_os = "macos")
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_linux() -> bool {
|
pub fn is_linux() -> bool {
|
||||||
if cfg!(target_os = "linux") {
|
cfg!(target_os = "linux")
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_macos_or_linux() -> bool {
|
pub fn is_macos_or_linux() -> bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user