adjective-adjective-animal/build.rs
Mark Rousskov 7b19b9e91b Remove stray semicolon (#1)
Remove stray semicolon
2019-10-13 12:25:30 -04:00

25 lines
809 B
Rust

use std::env;
use std::fs::File;
use std::io::{BufReader, BufWriter};
use std::io::prelude::*;
use std::path::Path;
fn main() {
generate(Path::new("data").join("adjectives.txt").as_path(),
Path::new(&env::var("OUT_DIR").unwrap()).join("adjectives.rs").as_path());
generate(Path::new("data").join("animals.txt").as_path(),
Path::new(&env::var("OUT_DIR").unwrap()).join("animals.rs").as_path());
}
fn generate(src_path: &Path, dst_path: &Path) {
let src = File::open(src_path).unwrap();
let src = BufReader::new(src);
let dst = File::create(dst_path).unwrap();
let mut dst = BufWriter::new(dst);
write!(dst, "[\n").unwrap();
for word in src.lines() {
write!(dst, "\"{}\",\n", &word.unwrap()).unwrap();
}
write!(dst, "]\n").unwrap();
}