1 2 3 4 5 6 7 8 9 10 11 12
use std::{fs::File, io::Read, path::Path}; pub fn read_file_to_string<P>(path: P) -> std::io::Result<String> where P: AsRef<Path>, { let mut file = File::open(path)?; let mut buf = String::new(); file.read_to_string(&mut buf)?; Ok(buf) }