summaryrefslogtreecommitdiffstats
path: root/src/utils.rs
blob: c873f45aa9ccaff12ada69f56160c15bde7955e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
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)
}