summaryrefslogtreecommitdiff
path: root/gen-dev-cargo-toml/src
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-14 03:13:33 +0200
committermo8it <mo8it@proton.me>2024-04-14 03:13:33 +0200
commit9831cbb13975cd0f5ee4c295156102e3573ede1a (patch)
tree765860366336f3eb79ece8aa169d65019f9c147d /gen-dev-cargo-toml/src
parentbee62c89de09fdd9823cba81e07f0f8528fe8ef9 (diff)
Fix tests
Diffstat (limited to 'gen-dev-cargo-toml/src')
-rw-r--r--gen-dev-cargo-toml/src/main.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/gen-dev-cargo-toml/src/main.rs b/gen-dev-cargo-toml/src/main.rs
index 9a7c1bb..792fe5f 100644
--- a/gen-dev-cargo-toml/src/main.rs
+++ b/gen-dev-cargo-toml/src/main.rs
@@ -10,18 +10,18 @@ use std::{
};
#[derive(Deserialize)]
-struct Exercise {
+struct ExerciseInfo {
name: String,
- path: String,
+ dir: Option<String>,
}
#[derive(Deserialize)]
-struct InfoToml {
- exercises: Vec<Exercise>,
+struct InfoFile {
+ exercises: Vec<ExerciseInfo>,
}
fn main() -> Result<()> {
- let exercises = toml_edit::de::from_str::<InfoToml>(
+ let exercise_infos = toml_edit::de::from_str::<InfoFile>(
&fs::read_to_string("info.toml").context("Failed to read `info.toml`")?,
)
.context("Failed to deserialize `info.toml`")?
@@ -36,12 +36,16 @@ fn main() -> Result<()> {
bin = [\n",
);
- for exercise in exercises {
+ for exercise_info in exercise_infos {
buf.extend_from_slice(b" { name = \"");
- buf.extend_from_slice(exercise.name.as_bytes());
- buf.extend_from_slice(b"\", path = \"../");
- buf.extend_from_slice(exercise.path.as_bytes());
- buf.extend_from_slice(b"\" },\n");
+ buf.extend_from_slice(exercise_info.name.as_bytes());
+ buf.extend_from_slice(b"\", path = \"../exercises/");
+ if let Some(dir) = &exercise_info.dir {
+ buf.extend_from_slice(dir.as_bytes());
+ buf.extend_from_slice(b"/");
+ }
+ buf.extend_from_slice(exercise_info.name.as_bytes());
+ buf.extend_from_slice(b".rs\" },\n");
}
buf.extend_from_slice(