1 2 3 4 5 6 7 8 9
use std::fs; use std::path::Path; pub fn read_safe<P: AsRef<Path>>(path: P) -> String { match fs::read_to_string(path) { Ok(result) => result.to_owned(), Err(_) => "".to_owned(), } }