Continue work on types
This commit is contained in:
parent
2a7c660ba6
commit
3dff0167dd
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -281,6 +281,7 @@ name = "this_algoritm"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"s2",
|
"s2",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -12,4 +12,5 @@ members = [
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
serde="1"
|
||||||
s2="0.0.12"
|
s2="0.0.12"
|
||||||
|
7
types/Cargo.lock
generated
7
types/Cargo.lock
generated
@ -1,7 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
version = 3
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "types"
|
|
||||||
version = "0.1.0"
|
|
@ -22,20 +22,22 @@ fn main() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Write it to an array containing all words
|
// Write it to an array containing all words
|
||||||
|
{
|
||||||
writeln!(
|
writeln!(
|
||||||
&mut file,
|
&mut file,
|
||||||
r#"/// Static array of `Word`
|
r#"/// Static array of `Word`
|
||||||
pub const WORDS: &[Word] = &["#
|
pub const WORDS: &[Word] = &["#
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
for result in words.iter() {
|
for result in words.iter() {
|
||||||
writeln!(&mut file, "{result:?},").unwrap();
|
writeln!(&mut file, "\n{result:?},").unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writeln!(&mut file, "];\n").unwrap();
|
writeln!(&mut file, "];\n").unwrap();
|
||||||
|
|
||||||
// Make a mapping of all caps word to a reference to the `Word` entry
|
// Make a mapping of all caps word to a reference to the `Word` entry
|
||||||
|
{
|
||||||
let mut word_map = phf_codegen::Map::new();
|
let mut word_map = phf_codegen::Map::new();
|
||||||
for (idx, word) in words.iter().enumerate() {
|
for (idx, word) in words.iter().enumerate() {
|
||||||
let idx_str = format!("&WORDS[{idx}]");
|
let idx_str = format!("&WORDS[{idx}]");
|
||||||
@ -48,9 +50,11 @@ fn main() {
|
|||||||
{};"#,
|
{};"#,
|
||||||
word_map.build()
|
word_map.build()
|
||||||
)
|
)
|
||||||
|
}
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Make a mapping of numbers to `Word`s
|
// Make a mapping of numbers to `Word`s
|
||||||
|
{
|
||||||
let word_number_to_idx = words
|
let word_number_to_idx = words
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
@ -74,6 +78,7 @@ fn main() {
|
|||||||
writeln!(&mut file, "],").unwrap();
|
writeln!(&mut file, "],").unwrap();
|
||||||
}
|
}
|
||||||
writeln!(&mut file, "];\n").unwrap();
|
writeln!(&mut file, "];\n").unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
Loading…
Reference in New Issue
Block a user