Function to_file

Source
pub fn to_file<P, T>(path: P, v: &T) -> Result<(), Error>
where P: AsRef<Path>, T: Serialize,
Expand description

Serialize data into an environment variable file.

§Example

use std::path::PathBuf;
use serde_envfile::{Value, to_file};

let value = Value::from_iter([("KEY", "VALUE")]);
let path = PathBuf::from(".env");

to_file(&path, &value).expect("Failed to serialize to file");