diff options
| author | mo8it <mo8it@proton.me> | 2024-05-25 18:19:30 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-05-25 18:19:30 +0200 |
| commit | beb7b24e8e9fe05cbcfaaf4676d52f63351fad16 (patch) | |
| tree | 782637ddff0e58c6fddcab257e0619768396b50f /src/embedded.rs | |
| parent | 990c68efcba8e1e2b7f2d8c5b6c16885d3920010 (diff) | |
Add solutions to bins
Diffstat (limited to 'src/embedded.rs')
| -rw-r--r-- | src/embedded.rs | 18 |
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"); |
