forked from MightyPork/crsn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
317 B
15 lines
317 B
4 years ago
|
use std::fs::File;
|
||
|
use std::io;
|
||
|
use std::io::Read;
|
||
|
use std::path::Path;
|
||
|
|
||
|
/// Read a file to string
|
||
|
pub fn read_file<P: AsRef<Path>>(path: P) -> io::Result<String> {
|
||
|
let path = path.as_ref();
|
||
|
let mut file = File::open(path)?;
|
||
|
|
||
|
let mut buf = String::new();
|
||
|
file.read_to_string(&mut buf)?;
|
||
|
Ok(buf)
|
||
|
}
|