Files
starship/src/utils.rs
T

13 lines
308 B
Rust
Raw Normal View History

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