Use env::var_os to read paths from the environment

This avoids unnecessary UTF-8 validation on OsStrings that we just pass
back to the OS.
This commit is contained in:
Matt Brubeck 2017-10-20 09:03:21 -07:00
parent fe16c1d5c3
commit c169f52b25
7 changed files with 19 additions and 18 deletions

View file

@ -10,7 +10,7 @@ use std::io::{BufReader, BufRead};
use std::path::Path;
fn main() {
let static_atoms = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("static_atoms.txt");
let static_atoms = Path::new(&env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("static_atoms.txt");
let static_atoms = BufReader::new(File::open(&static_atoms).unwrap());
let mut atom_type = string_cache_codegen::AtomType::new("Atom", "atom!");
@ -27,6 +27,6 @@ fn main() {
atom_type
.atoms(static_atoms.lines().map(Result::unwrap))
.write_to_file(&Path::new(&env::var("OUT_DIR").unwrap()).join("atom.rs"))
.write_to_file(&Path::new(&env::var_os("OUT_DIR").unwrap()).join("atom.rs"))
.unwrap();
}