Function fsio::file::append_text_file
source · [−]Expand description
Appends (or creates) and writes the text to the requested file path. If a file exists at that path, the content will be appended.
Arguments
path
- The file pathtext
- The file text content
Example
use crate::fsio::file;
use std::path::Path;
fn main() {
let file_path = "./target/__test/file_test/append_text_file/file.txt";
let mut result = file::write_text_file(file_path, "some content");
assert!(result.is_ok());
result = file::append_text_file(file_path, "\nmore content");
assert!(result.is_ok());
let text = file::read_text_file(file_path).unwrap();
assert_eq!(text, "some content\nmore content");
}