/// Reads the config file at the given path.
///
/// If there is no such file, returns `None`. If there is a file but it
/// is broken, aborts.
Reads the config file at the given path.
If there is no such file, returns `None`. If there is a file but it
is broken, aborts.
Reads the config file at the given path . If there is no such file returns ` None ` . If there is a file but it is broken aborts .
fn read(path: &Path) -> Result<Option<Self>, Error> {
        let mut file = match fs::File::open(path) {
            Ok(file) => file,
            Err(_) => return Ok(None)
        };
        let mut config = String::new();
        if let Err(err) = file.read_to_string(&mut config) {
            eprintln!(
                "Failed to read config file {}: {}",
                path.display(), err
            );
            return Err(Error);
        }
        Self::parse(&config, path).map(Some)
    }
fn read ( path : & Path ) -> Result < Option < Self > , Error > { let mut file = match fs :: File :: open ( path ) { Ok ( file ) => file , Err ( _ ) => return Ok ( None ) } ; let mut config = String :: new ( ) ; if let Err ( err ) = file . read_to_string ( & mut config ) { eprintln ! ( " " path display ( ) err ) ; return Err ( Error ) ; } Self :: parse ( & config , path ) . map ( Some ) }
Reads the config file at the given path.
Reads the config file at the given path .
path
&Path