Skip to content
Snippets Groups Projects
run_script.rs 330 B
Newer Older
Louis's avatar
Louis committed
use std::convert::AsRef;
use std::path::Path;
use std::fs::File;
use std::io::Read;

pub fn run_script<P: AsRef<Path>>(path: P) -> Option<String> {
    let mut file = File::open(&path).unwrap();
    let mut buf = String::new();

Louis's avatar
Louis committed
    match file.read_to_string(&mut buf) {
		Ok(_) => {},
		Err(_) => return None,
	}

Louis's avatar
Louis committed
    Some(buf)
}