rustvision/
files.rs

1/// Macro for loading a file from the disk.
2#[macro_export]
3macro_rules! load_file {
4    ($file_name:expr) => {
5        std::fs::read($file_name).expect("Should have been able to read the file")
6    };
7}
8
9/// Macro for writing a file to the disk.
10#[macro_export]
11macro_rules! write_file {
12    ($file_name:expr, $content:expr) => {
13        use std::io::prelude::*;
14        let mut file = std::fs::File::create($file_name).expect("File could not be opened");
15        file.write_all($content).expect("Could not write to file");
16    };
17}