fn file_create_write<P, F, E>(path: P, write_fn: F) -> Result<()>
where
    P: AsRef<Path>,
    F: FnOnce(&mut File) -> std::result::Result<(), E>,
    std::result::Result<(), E>: crate::errors::ResultExt<()>,
{
    let path = path.as_ref();
    let mut f = ctry!(File::create(path); "couldn't open {} for writing",
                      path.display());
    ctry!(write_fn(&mut f); "couldn't write to {}", path.display());
    Ok(())
}
/// A convenience method to provide a better error message when writing to a created file.
A convenience method to provide a better error message when writing to a created file.
A convenience method to provide a better error message when writing to a created file .
fn file_create_write<P, F, E>(path: P, write_fn: F) -> Result<()>
where
    P: AsRef<Path>,
    F: FnOnce(&mut File) -> std::result::Result<(), E>,
    std::result::Result<(), E>: crate::errors::ResultExt<()>,
{
    let path = path.as_ref();
    let mut f = ctry!(File::create(path); "couldn't open {} for writing",
                      path.display());
    ctry!(write_fn(&mut f); "couldn't write to {}", path.display());
    Ok(())
}
fn file_create_write < P , F , E > ( path : P , write_fn : F ) -> Result < ( ) > where P : AsRef < Path > , F : FnOnce ( & mut File ) -> std :: result :: Result < ( ) , E > , std :: result :: Result < ( ) , E > : crate :: errors :: ResultExt < ( ) > , { let path = path . as_ref ( ) ; let mut f = ctry ! ( File create ( path ) " " path display ( ) ) ; ctry ! ( write_fn ( mut f ) " " path display ( ) ) ; Ok ( ( ) ) }
A convenience method to provide a better error message when writing to a created file.
A convenience method to provide a better error message when writing to a created file .
path
P
write_fn
F