2019-06-10 14:56:17 +00:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io::{Read, Result};
|
2019-09-05 16:45:04 +00:00
|
|
|
use std::path::Path;
|
2019-06-10 14:56:17 +00:00
|
|
|
|
|
|
|
/// Return the string contents of a file
|
2019-09-05 16:45:04 +00:00
|
|
|
pub fn read_file<P: AsRef<Path>>(file_name: P) -> Result<String> {
|
2019-06-10 14:56:17 +00:00
|
|
|
let mut file = File::open(file_name)?;
|
|
|
|
let mut data = String::new();
|
|
|
|
|
|
|
|
file.read_to_string(&mut data)?;
|
|
|
|
Ok(data)
|
|
|
|
}
|