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