summaryrefslogtreecommitdiff
path: root/src/embedded.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/embedded.rs')
-rw-r--r--src/embedded.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/embedded.rs b/src/embedded.rs
index e710a4e..1dce46c 100644
--- a/src/embedded.rs
+++ b/src/embedded.rs
@@ -1,6 +1,6 @@
use anyhow::{Context, Error, Result};
use std::{
- fs::{create_dir, create_dir_all, OpenOptions},
+ fs::{create_dir, OpenOptions},
io::{self, Write},
};
@@ -43,8 +43,8 @@ struct ExerciseFiles {
}
// A directory in the `exercises/` directory.
-struct ExerciseDir {
- name: &'static str,
+pub struct ExerciseDir {
+ pub name: &'static str,
readme: &'static [u8],
}
@@ -78,7 +78,7 @@ pub struct EmbeddedFiles {
/// The content of the `info.toml` file.
pub info_file: &'static str,
exercise_files: &'static [ExerciseFiles],
- exercise_dirs: &'static [ExerciseDir],
+ pub exercise_dirs: &'static [ExerciseDir],
}
impl EmbeddedFiles {
@@ -121,13 +121,9 @@ impl EmbeddedFiles {
// 14 = 10 + 1 + 3
// solutions/ + / + .rs
- let mut dir_path = String::with_capacity(14 + dir.name.len() + exercise_name.len());
- dir_path.push_str("solutions/");
- dir_path.push_str(dir.name);
- create_dir_all(&dir_path)
- .with_context(|| format!("Failed to create the directory {dir_path}"))?;
-
- let mut solution_path = dir_path;
+ let mut solution_path = String::with_capacity(14 + dir.name.len() + exercise_name.len());
+ solution_path.push_str("solutions/");
+ solution_path.push_str(dir.name);
solution_path.push('/');
solution_path.push_str(exercise_name);
solution_path.push_str(".rs");