diff --git a/crates/typos-dict/src/lib.rs b/crates/typos-dict/src/lib.rs index 9f5d62a..808bec0 100644 --- a/crates/typos-dict/src/lib.rs +++ b/crates/typos-dict/src/lib.rs @@ -1,3 +1,3 @@ -mod dict_codegen; +mod word_codegen; -pub use crate::dict_codegen::WORD_TRIE; +pub use crate::word_codegen::WORD_TRIE; diff --git a/crates/typos-dict/src/dict_codegen.rs b/crates/typos-dict/src/word_codegen.rs similarity index 100% rename from crates/typos-dict/src/dict_codegen.rs rename to crates/typos-dict/src/word_codegen.rs diff --git a/crates/typos-dict/tests/codegen.rs b/crates/typos-dict/tests/codegen.rs index e7c393a..fb6a317 100644 --- a/crates/typos-dict/tests/codegen.rs +++ b/crates/typos-dict/tests/codegen.rs @@ -1,16 +1,15 @@ -const DICT: &[u8] = include_bytes!("../assets/words.csv"); - #[test] fn codegen() { let mut content = vec![]; - generate(&mut content); + const DICT: &[u8] = include_bytes!("../assets/words.csv"); + generate(&mut content, "WORD", DICT); let content = String::from_utf8(content).unwrap(); let content = codegenrs::rustfmt(&content, None).unwrap(); - snapbox::assert_eq_path("./src/dict_codegen.rs", content); + snapbox::assert_eq_path("./src/word_codegen.rs", content); } -fn generate(file: &mut W) { +fn generate(file: &mut W, prefix: &str, dict: &[u8]) { writeln!( file, "// This file is @generated by {}", @@ -23,13 +22,13 @@ fn generate(file: &mut W) { let records: Vec<_> = csv::ReaderBuilder::new() .has_headers(false) .flexible(true) - .from_reader(DICT) + .from_reader(dict) .records() .map(|r| r.unwrap()) .collect(); dictgen::generate_trie( file, - "WORD", + prefix, "&'static [&'static str]", records.iter().map(|record| { let mut record_fields = record.iter();