1
0
mirror of https://github.com/jht5945/rust_util.git synced 2025-12-27 15:40:03 +08:00

fix: add loop count

This commit is contained in:
2020-08-02 14:44:02 +08:00
parent 31a2910393
commit d8d52abd5b

View File

@@ -83,7 +83,7 @@ pub fn find_parents_exists_file(file: &str) -> Option<PathBuf> {
Err(_) => None,
Ok(mut path) => loop {
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() {
return Some(path);
}
@@ -100,7 +100,7 @@ pub fn find_parents_exists_dir(dir: &str) -> Option<PathBuf> {
Err(_) => None,
Ok(mut path) => loop {
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() {
return Some(path);
}