mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-27 15:40:03 +08:00
chore: loop_count
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rust_util"
|
name = "rust_util"
|
||||||
version = "0.6.2"
|
version = "0.6.3"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Hatter's Rust Util"
|
description = "Hatter's Rust Util"
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ use std::{
|
|||||||
path::{ Path, PathBuf },
|
path::{ Path, PathBuf },
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use crate::{
|
||||||
iff,
|
iff,
|
||||||
util_os,
|
util_os,
|
||||||
util_io,
|
util_io,
|
||||||
|
util_msg,
|
||||||
new_box_ioerror,
|
new_box_ioerror,
|
||||||
XResult,
|
XResult,
|
||||||
};
|
};
|
||||||
@@ -83,7 +84,10 @@ pub fn find_parents_exists_file(file: &str) -> Option<PathBuf> {
|
|||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
Ok(mut path) => loop {
|
Ok(mut path) => loop {
|
||||||
loop_count += 1;
|
loop_count += 1;
|
||||||
if loop_count > 1000 { panic!("Loop count more than 1000!"); }
|
if loop_count > 1000 {
|
||||||
|
util_msg::print_error("Loop count more than 1000!");
|
||||||
|
return None;
|
||||||
|
}
|
||||||
if path.join(file).is_file() {
|
if path.join(file).is_file() {
|
||||||
return Some(path);
|
return Some(path);
|
||||||
}
|
}
|
||||||
@@ -100,7 +104,10 @@ pub fn find_parents_exists_dir(dir: &str) -> Option<PathBuf> {
|
|||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
Ok(mut path) => loop {
|
Ok(mut path) => loop {
|
||||||
loop_count += 1;
|
loop_count += 1;
|
||||||
if loop_count > 1000 { panic!("Loop count more than 1000!"); }
|
if loop_count > 1000 {
|
||||||
|
util_msg::print_error("Loop count more than 1000!");
|
||||||
|
return None;
|
||||||
|
}
|
||||||
if path.join(dir).is_dir() {
|
if path.join(dir).is_dir() {
|
||||||
return Some(path);
|
return Some(path);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user