1
0
mirror of https://github.com/jht5945/finding.git synced 2025-12-27 21:20:05 +08:00
This commit is contained in:
2019-07-21 22:57:23 +08:00
parent 369bd6ffa8
commit b9fc73a1e6

View File

@@ -24,11 +24,11 @@ fn check_path(path: &Path) {
//println!("-------------- {:?} {}", path, path.is_dir());
}
fn list_dir(dir: &Path, fnc: fn(&Path) -> ()) -> XResult<()> {
fn list_dir<F>(dir: &Path, fnc: &F) -> XResult<()> where F: Fn(&Path) -> () {
list_dir_with_depth_check(&mut 0u32, dir, fnc)
}
fn list_dir_with_depth_check(depth: &mut u32, dir: &Path, fnc: fn(&Path) -> ()) -> XResult<()> {
fn list_dir_with_depth_check<F>(depth: &mut u32, dir: &Path, fnc: &F) -> XResult<()> where F: Fn(&Path) -> () {
if *depth > 100u32 {
// TODO error: return Err(Box::new("depth"));
}
@@ -76,7 +76,8 @@ fn main() {
println!("{:?}", get_absolute_path("~/.jssp"));
println!("{:?}", get_absolute_path("~/.jsspx"));
list_dir(get_absolute_path("~").unwrap().as_path(), check_path).ok();
//list_dir(get_absolute_path("~").unwrap().as_path(), &check_path).ok();
list_dir(get_absolute_path("~").unwrap().as_path(), &|_| {}).ok();
println!("Hello, world!");
}