fn try_create_file(path: &Path) -> Result<Option<File>, io::Error> {
    fs::create_dir_all(path.parent().unwrap())?;
    match fs::OpenOptions::new()
        .write(true)
        .create_new(true)
        .open(&path)
    {
        Ok(file) => Ok(Some(file)),
        Err(e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(None),
        Err(e) => Err(e),
    }
}
/// Tries to create a file, returning Ok(None) if a file already exists at path
Tries to create a file, returning Ok(None) if a file already exists at path
Tries to create a file returning Ok ( None ) if a file already exists at path
fn try_create_file(path: &Path) -> Result<Option<File>, io::Error> {
    fs::create_dir_all(path.parent().unwrap())?;
    match fs::OpenOptions::new()
        .write(true)
        .create_new(true)
        .open(&path)
    {
        Ok(file) => Ok(Some(file)),
        Err(e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(None),
        Err(e) => Err(e),
    }
}
fn try_create_file ( path : & Path ) -> Result < Option < File > , io :: Error > { fs :: create_dir_all ( path . parent ( ) . unwrap ( ) ) ? ; match fs :: OpenOptions :: new ( ) . write ( true ) . create_new ( true ) . open ( & path ) { Ok ( file ) => Ok ( Some ( file ) ) , Err ( e ) if e . kind ( ) == io :: ErrorKind :: AlreadyExists => Ok ( None ) , Err ( e ) => Err ( e ) , } }
Tries to create a file, returning Ok(None) if a file already exists at path
Tries to create a file returning Ok ( None ) if a file already exists at path
path
&Path
path
&Path