Add solutions to bins

This commit is contained in:
mo8it
2024-05-25 18:19:30 +02:00
parent 990c68efcb
commit beb7b24e8e
5 changed files with 75 additions and 13 deletions
+19
View File
@@ -1,4 +1,5 @@
use anyhow::{Context, Result};
use std::path::Path;
use crate::info_file::ExerciseInfo;
@@ -40,6 +41,24 @@ pub fn append_bins(
}
buf.extend_from_slice(exercise_info.name.as_bytes());
buf.extend_from_slice(b".rs\" },\n");
let sol_path = exercise_info.sol_path();
if !Path::new(&sol_path).exists() {
continue;
}
buf.extend_from_slice(b" { name = \"");
buf.extend_from_slice(exercise_info.name.as_bytes());
buf.extend_from_slice(b"_sol");
buf.extend_from_slice(b"\", path = \"");
buf.extend_from_slice(exercise_path_prefix);
buf.extend_from_slice(b"solutions/");
if let Some(dir) = &exercise_info.dir {
buf.extend_from_slice(dir.as_bytes());
buf.push(b'/');
}
buf.extend_from_slice(exercise_info.name.as_bytes());
buf.extend_from_slice(b".rs\" },\n");
}
}