2018-09-16 14:25:41 +03:00
|
|
|
use std::{env, path::Path};
|
2017-12-22 15:51:36 +03:00
|
|
|
|
2022-09-09 11:05:51 +03:00
|
|
|
#[cfg(all(feature = "rkyv-impl", feature = "rkyv-bytecheck-impl"))]
|
|
|
|
compile_error!("Cannot enable bytechcked, non-bytechecked rkyv both");
|
|
|
|
|
2017-12-22 15:51:36 +03:00
|
|
|
fn main() {
|
2019-01-07 13:43:47 +03:00
|
|
|
let strs = include_str!("words.txt")
|
|
|
|
.lines()
|
|
|
|
.map(|l| l.trim())
|
|
|
|
.collect::<Vec<_>>();
|
2018-11-17 10:38:23 +03:00
|
|
|
gen("js_word", "JsWord", &strs);
|
2017-12-22 15:51:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn gen(mac_name: &str, type_name: &str, atoms: &[&str]) {
|
|
|
|
string_cache_codegen::AtomType::new(type_name, &format!("{}!", mac_name))
|
|
|
|
.atoms(atoms)
|
2022-10-13 09:09:44 +03:00
|
|
|
.with_atom_doc(
|
|
|
|
"
|
|
|
|
[JsWord] is an interned string.
|
|
|
|
|
|
|
|
This type should be used instead of [String] for values, because lots of
|
|
|
|
values are duplicated. For example, if an identifier is named `myVariable`,
|
|
|
|
there will be lots of identifier usages with the value `myVariable`.
|
|
|
|
|
|
|
|
This type
|
|
|
|
- makes equality comparison faster.
|
|
|
|
- reduces memory usage.
|
|
|
|
",
|
|
|
|
)
|
2017-12-22 15:51:36 +03:00
|
|
|
.write_to_file(&Path::new(&env::var("OUT_DIR").unwrap()).join(format!("{}.rs", mac_name)))
|
|
|
|
.unwrap();
|
|
|
|
}
|