fn path_contains_file(path: &Path) -> Option<&Path> {
    let mut p: &Path = path;

    loop {
        if p.is_file() {
            return Some(p);
        }
        match p.parent() {
            Some(parent) => {
                p = parent;
            }
            None => break,
        }
    }
    None
}
// detects if a path contains a file at any level.
//   eg    /tmp/foo/somefile/bar/other
//   if somefile exists and is a file, it will be returned.
detects if a path contains a file at any level.
detects if a path contains a file at any level .
fn path_contains_file(path: &Path) -> Option<&Path> {
    let mut p: &Path = path;
    loop {
        if p.is_file() {
            return Some(p);
        }
        match p.parent() {
            Some(parent) => {
                p = parent;
            }
            None => break,
        }
    }
    None
}
fn path_contains_file ( path : & Path ) -> Option < & Path > { let mut p : & Path = path ; loop { if p . is_file ( ) { return Some ( p ) ; } match p . parent ( ) { Some ( parent ) => { p = parent ; } None => break , } } None }
detects if a path contains a file at any level.
detects if a path contains a file at any level .
path
&Path