pub fn init(path: &Path) -> Result<ApplicationCfg, io::Error> {
        match File::open(path) {
            Ok(mut file) => {
                let mut buffer = String::new();
                file.read_to_string(&mut buffer)?;
                let cfg = toml::from_str(&buffer)?;
                Ok(cfg)
            }
            Err(e) => {
                // Missing config file is fine and expected during local execution.
                if e.kind() == io::ErrorKind::NotFound {
                    eprintln!(
                        "{} not found => Using empty default configuration.",
                        path.to_string_lossy()
                    );
                    Ok(ApplicationCfg::default())
                } else {
                    let err = e;
                    eprintln!("{}", err);
                    Err(err)
                }
            }
        }
    }
/// Checks for a file named `application.cfg` in the working directory. It is then used to
/// create a new configuration. If the file can not be found a default configuration is created.
Checks for a file named `application.cfg` in the working directory. It is then used to
create a new configuration. If the file can not be found a default configuration is created.
Checks for a file named ` application . cfg ` in the working directory . It is then used to create a new configuration . If the file can not be found a default configuration is created .
pub fn init(path: &Path) -> Result<ApplicationCfg, io::Error> {
        match File::open(path) {
            Ok(mut file) => {
                let mut buffer = String::new();
                file.read_to_string(&mut buffer)?;
                let cfg = toml::from_str(&buffer)?;
                Ok(cfg)
            }
            Err(e) => {
                // Missing config file is fine and expected during local execution.
                if e.kind() == io::ErrorKind::NotFound {
                    eprintln!(
                        "{} not found => Using empty default configuration.",
                        path.to_string_lossy()
                    );
                    Ok(ApplicationCfg::default())
                } else {
                    let err = e;
                    eprintln!("{}", err);
                    Err(err)
                }
            }
        }
    }
pub fn init ( path : & Path ) -> Result < ApplicationCfg , io :: Error > { match File :: open ( path ) { Ok ( mut file ) => { let mut buffer = String :: new ( ) ; file . read_to_string ( & mut buffer ) ? ; let cfg = toml :: from_str ( & buffer ) ? ; Ok ( cfg ) } Err ( e ) => { // Missing config file is fine and expected during local execution. if e . kind ( ) == io :: ErrorKind :: NotFound { eprintln ! ( " " path to_string_lossy ( ) ) ; Ok ( ApplicationCfg :: default ( ) ) } else { let err = e ; eprintln ! ( " " err ) ; Err ( err ) } } } }
Checks for a file named `application.cfg` in the working directory.
Checks for a file named ` application . cfg ` in the working directory .
path
&Path
path
&Path