pub fn save_config_file<T, P>(config: &T, config_file: P) -> Result<(), io::Error>
where
    T: serde::ser::Serialize,
    P: AsRef<Path>,
{
    let serialized = serde_yaml::to_string(config)
        .map_err(|err| io::Error::new(io::ErrorKind::Other, format!("{:?}", err)))?;

    if let Some(outdir) = config_file.as_ref().parent() {
        create_dir_all(outdir)?;
    }
    let mut file = File::create(config_file)?;
    file.write_all(&serialized.into_bytes())?;

    Ok(())
}
/// Save a value to a file in YAML format.
///
/// Despite the name, this function is a generic YAML file serializer, a thin
/// wrapper around serde.
///
/// If the file's directory does not exist, it will be created. If the file
/// already exists, it will be overwritten.
///
/// Most callers should instead use [`Config::save`].
///
/// # Errors
///
/// This function may return typical file I/O errors.
Save a value to a file in YAML format.
Despite the name, this function is a generic YAML file serializer, a thin
wrapper around serde.

If the file's directory does not exist, it will be created. If the file
already exists, it will be overwritten.

Most callers should instead use [`Config::save`].
Save a value to a file in YAML format . Despite the name this function is a generic YAML file serializer a thin wrapper around serde . If the file ' s directory does not exist it will be created . If the file already exists it will be overwritten . Most callers should instead use [ ` Config :: save ` ] .
pub fn save_config_file<T, P>(config: &T, config_file: P) -> Result<(), io::Error>
where
    T: serde::ser::Serialize,
    P: AsRef<Path>,
{
    let serialized = serde_yaml::to_string(config)
        .map_err(|err| io::Error::new(io::ErrorKind::Other, format!("{:?}", err)))?;
    if let Some(outdir) = config_file.as_ref().parent() {
        create_dir_all(outdir)?;
    }
    let mut file = File::create(config_file)?;
    file.write_all(&serialized.into_bytes())?;
    Ok(())
}
pub fn save_config_file < T , P > ( config : & T , config_file : P ) -> Result < ( ) , io :: Error > where T : serde :: ser :: Serialize , P : AsRef < Path > , { let serialized = serde_yaml :: to_string ( config ) . map_err ( | err | io :: Error :: new ( io :: ErrorKind :: Other , format ! ( " " err ) ) ) ? ; if let Some ( outdir ) = config_file . as_ref ( ) . parent ( ) { create_dir_all ( outdir ) ? ; } let mut file = File :: create ( config_file ) ? ; file . write_all ( & serialized . into_bytes ( ) ) ? ; Ok ( ( ) ) }
Save a value to a file in YAML format.
Save a value to a file in YAML format .
config
&T
config_file
P
errors
This function may return typical file I/O errors.
This function may return typical file I / O errors .