1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;

pub fn read_to_string<P: AsRef<Path>>(path: P) -> String {
    let mut file = File::open(path).expect("Error: openning the file");
    let mut contents = String::new();
    file.read_to_string(&mut contents)
        .expect("Error: reading the file");
    contents
}