Suitably random and reasonably unique human readable (and fairly adorable) ids, ala GiphyCat
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
809 B

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();
}