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
+24
View File
@@ -49,6 +49,30 @@ impl ExerciseInfo {
path
}
/// Path to the solution file starting with the `solutions/` directory.
pub fn sol_path(&self) -> String {
let mut path = if let Some(dir) = &self.dir {
// 14 = 10 + 1 + 3
// solutions/ + / + .rs
let mut path = String::with_capacity(14 + dir.len() + self.name.len());
path.push_str("solutions/");
path.push_str(dir);
path.push('/');
path
} else {
// 13 = 10 + 3
// solutions/ + .rs
let mut path = String::with_capacity(13 + self.name.len());
path.push_str("solutions/");
path
};
path.push_str(&self.name);
path.push_str(".rs");
path
}
}
/// The deserialized `info.toml` file.