pub fn write_string<Path: AsRef<str>, Text: AsRef<str>>(
file_path: &Path,
text: &Text,
) -> Result<()>Expand description
Writes text to a file. This function will create the file and its full directory path if they don’t exist, and will entirely replace the contents.
§Parameters
file_path: borrowedAsRef<str>such asStringor&strtext: borrowedAsRef<str>such asStringor&str
§Returns
Result<()>
§Examples
fn main() -> std::io::Result<()> {
Ok({
let file_path: &str = "write_to/absolute_or_relative.path";
let file_path: String = String::from(file_path);
let text: &str = "Hello, World!";
let text: String = String::from(text);
file_access::write_string(&file_path, &text)?;
// Clean-up:
file_access::delete(&"write_to")?; // ./write_to/
})
}