Crates.io | write-to-file |
lib.rs | write-to-file |
version | 1.0.2 |
source | src |
created_at | 2022-05-11 09:49:13.562813 |
updated_at | 2022-05-11 10:05:43.883405 |
description | Write to a file, simple helper fn and traits lib crate. |
homepage | |
repository | https://github.com/usagi/fold-license |
max_upload_size | |
id | 584573 |
size | 10,419 |
Write to a file, simple helper fn and traits lib crate.
I'm tired to implements these very simple file writing feature, but I don't need more a rich features. So I publish the crate. Enjoy rust in relaxed. 🤗
use write_to_file::write_to_file;
// write binary
let buf = vec![1u8, 2, 3, 4];
let path = "target/test/file.bin";
write_to_file(path, buf).unwrap(); // <- Easy to write!
// write text
let buf = "Nyanko is one of the greatest life.".to_string();
let path = "target/test/file.txt";
write_to_file(path, buf).unwrap(); // <- Easy to write!
use write_to_file::WriteToFile;
// Vec<u8>
let buf: Vec<u8> = vec![1u8, 2, 3, 4];
let path = "target/test/file.bin";
buf.write_to_file(path).unwrap(); // <- Easy to write!
// &[u8]
let buf: &[u8] = buf.as_slice();
let path = "target/test/file.bin";
buf.write_to_file(path).unwrap(); // <- Easy to write!
// String
let buf: String = "Nyanko is one of the greatest life.".to_string();
let path = "target/test/file.txt";
buf.write_to_file(path).unwrap(); // <- Easy to write!
// &str
let buf: &str = buf.as_str();
let path = "target/test/file.txt";
buf.write_to_file(path).unwrap(); // <- Easy to write!