summaryrefslogtreecommitdiff
path: root/src/info_file.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-05-25 18:19:30 +0200
committermo8it <mo8it@proton.me>2024-05-25 18:19:30 +0200
commitbeb7b24e8e9fe05cbcfaaf4676d52f63351fad16 (patch)
tree782637ddff0e58c6fddcab257e0619768396b50f /src/info_file.rs
parent990c68efcba8e1e2b7f2d8c5b6c16885d3920010 (diff)
Add solutions to bins
Diffstat (limited to 'src/info_file.rs')
-rw-r--r--src/info_file.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/info_file.rs b/src/info_file.rs
index 0c45928..5ea487f 100644
--- a/src/info_file.rs
+++ b/src/info_file.rs
@@ -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.