pub fn write_to_file<P, T>(path: P, buf: T) -> Result<()> where
    P: AsRef<Path>,
    T: AsRef<[u8]>, 
Expand description

Write buf to path, with create required directories if not exists.

// write binary
let buf = vec![1u8, 2, 3, 4]; // Both of Vec<u8> and &[u8] are supported.
let path = "target/test/path/to/file.bin";
write_to_file::write_to_file(path, buf);
// write text
let buf = "Nyanko is one of the greatest life."; // Both of String and str are supported.
let path = "target/test/path/to/file.txt";
write_to_file::write_to_file(path, buf);