pub fn discover_from_path(start_from: PathBuf) -> Result<Option<WithPath<Manifest>>> {
        let mut cwd_opt = Some(start_from.as_path());

        while let Some(cwd) = cwd_opt {
            for f in fs::read_dir(cwd).with_context(|| {
                format!("Error reading the directory with path: {}", cwd.display())
            })? {
                let p = f
                    .with_context(|| {
                        format!("Error reading the directory with path: {}", cwd.display())
                    })?
                    .path();
                if let Some(filename) = p.file_name() {
                    if filename.to_str() == Some("Cargo.toml") {
                        let m = WithPath::new(Manifest::from_path(&p)?, p);
                        return Ok(Some(m));
                    }
                }
            }

            // Not found. Go up a directory level.
            cwd_opt = cwd.parent();
        }

        Ok(None)
    }
// Climbs each parent directory from a given starting directory until we find a Cargo.toml.
Climbs each parent directory from a given starting directory until we find a Cargo.toml.
Climbs each parent directory from a given starting directory until we find a Cargo . toml .
pub fn discover_from_path(start_from: PathBuf) -> Result<Option<WithPath<Manifest>>> {
        let mut cwd_opt = Some(start_from.as_path());
        while let Some(cwd) = cwd_opt {
            for f in fs::read_dir(cwd).with_context(|| {
                format!("Error reading the directory with path: {}", cwd.display())
            })? {
                let p = f
                    .with_context(|| {
                        format!("Error reading the directory with path: {}", cwd.display())
                    })?
                    .path();
                if let Some(filename) = p.file_name() {
                    if filename.to_str() == Some("Cargo.toml") {
                        let m = WithPath::new(Manifest::from_path(&p)?, p);
                        return Ok(Some(m));
                    }
                }
            }
            // Not found. Go up a directory level.
            cwd_opt = cwd.parent();
        }
        Ok(None)
    }
pub fn discover_from_path ( start_from : PathBuf ) -> Result < Option < WithPath < Manifest > > > { let mut cwd_opt = Some ( start_from . as_path ( ) ) ; while let Some ( cwd ) = cwd_opt { for f in fs :: read_dir ( cwd ) . with_context ( | | { format ! ( " " cwd display ( ) ) } ) ? { let p = f . with_context ( | | { format ! ( " " cwd display ( ) ) } ) ? . path ( ) ; if let Some ( filename ) = p . file_name ( ) { if filename . to_str ( ) == Some ( " " ) { let m = WithPath :: new ( Manifest :: from_path ( & p ) ? , p ) ; return Ok ( Some ( m ) ) ; } } } // Not found. Go up a directory level. cwd_opt = cwd . parent ( ) ; } Ok ( None ) }
Climbs each parent directory from a given starting directory until we find a Cargo.toml.
Climbs each parent directory from a given starting directory until we find a Cargo . toml .
start_from
PathBuf