mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-28 16:10:05 +08:00
fix: add loop count
This commit is contained in:
@@ -83,7 +83,7 @@ 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 > 100 { panic!("Loop count more than 100!"); }
|
if loop_count > 1000 { panic!("Loop count more than 1000!"); }
|
||||||
if path.join(file).is_file() {
|
if path.join(file).is_file() {
|
||||||
return Some(path);
|
return Some(path);
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ 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 > 100 { panic!("Loop count more than 100!"); }
|
if loop_count > 1000 { panic!("Loop count more than 1000!"); }
|
||||||
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