summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-08-08 00:20:20 +0200
committermo8it <mo8it@proton.me>2024-08-08 00:41:12 +0200
commit693bb708b2af786b942e172d3aed104c0abd252e (patch)
treed9a488fd029c41b2a6176a3cc89eaef741750ec5
parent97719fe8da82a91a1919e55e1950d0997acca574 (diff)
Add README to the solutions dir
-rw-r--r--CHANGELOG.md1
-rw-r--r--solutions/README.md6
-rw-r--r--src/init.rs5
3 files changed, 12 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c014306..4b753d2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ cargo install rustlings
- Fix `rust-analyzer` rebuilding all exercises after changing one file.
- Show a helpful error message when trying to install Rustlings with a Rust version lower than the minimum one that Rustlings supports.
- Remove the state file and the solutions directory from the generated `.gitignore` file.
+- Add a `README.md` file to the `solutions/` directory.
- Run the final check of all exercises in parallel.
- Small exercise improvements.
- `dev check`: Check that all solutions are formatted with `rustfmt`.
diff --git a/solutions/README.md b/solutions/README.md
new file mode 100644
index 0000000..6a217fa
--- /dev/null
+++ b/solutions/README.md
@@ -0,0 +1,6 @@
+# Official Rustlings solutions
+
+Before you finish an exercise, its solution file will only contain an empty `main` function.
+The content of this file will be automatically replaced by the actual solution once you finish the exercise.
+
+Note that these solution are often only _one possibility_ to solve an exercise.
diff --git a/src/init.rs b/src/init.rs
index 9c7d10f..3970bb2 100644
--- a/src/init.rs
+++ b/src/init.rs
@@ -35,6 +35,11 @@ pub fn init() -> Result<()> {
.context("Failed to initialize the `rustlings/exercises` directory")?;
create_dir("solutions").context("Failed to create the `solutions/` directory")?;
+ fs::write(
+ "solutions/README.md",
+ include_bytes!("../solutions/README.md"),
+ )
+ .context("Failed to create the file rustlings/solutions/README.md")?;
for dir in EMBEDDED_FILES.exercise_dirs {
let mut dir_path = String::with_capacity(10 + dir.name.len());
dir_path.push_str("solutions/");