diff options
Diffstat (limited to 'src/utils.rs')
-rw-r--r-- | src/utils.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 index 000000000..c873f45aa --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,12 @@ +use std::fs::File; +use std::io::{Read, Result}; +use std::path::Path; + +/// Return the string contents of a file +pub fn read_file<P: AsRef<Path>>(file_name: P) -> Result<String> { + let mut file = File::open(file_name)?; + let mut data = String::new(); + + file.read_to_string(&mut data)?; + Ok(data) +} |