fn _discover() -> Result<Option<WithPath<Config>>> {
        let _cwd = std::env::current_dir()?;
        let mut cwd_opt = Some(_cwd.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("Anchor.toml") {
                        let cfg = Config::from_path(&p)?;
                        return Ok(Some(WithPath::new(cfg, p)));
                    }
                }
            }

            cwd_opt = cwd.parent();
        }

        Ok(None)
    }
// Climbs each parent directory until we find an Anchor.toml.
Climbs each parent directory until we find an Anchor.toml.
Climbs each parent directory until we find an Anchor . toml .
fn _discover() -> Result<Option<WithPath<Config>>> {
        let _cwd = std::env::current_dir()?;
        let mut cwd_opt = Some(_cwd.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("Anchor.toml") {
                        let cfg = Config::from_path(&p)?;
                        return Ok(Some(WithPath::new(cfg, p)));
                    }
                }
            }
            cwd_opt = cwd.parent();
        }
        Ok(None)
    }
fn _discover ( ) -> Result < Option < WithPath < Config > > > { let _cwd = std :: env :: current_dir ( ) ? ; let mut cwd_opt = Some ( _cwd . 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 cfg = Config :: from_path ( & p ) ? ; return Ok ( Some ( WithPath :: new ( cfg , p ) ) ) ; } } } cwd_opt = cwd . parent ( ) ; } Ok ( None ) }
Climbs each parent directory until we find an Anchor.toml.
Climbs each parent directory until we find an Anchor . toml .