diff options
| author | mo8it <mo8it@proton.me> | 2024-04-21 23:39:44 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-04-21 23:39:44 +0200 |
| commit | 30040d77781e03043e72d09d7fe8cf1cf5436a9c (patch) | |
| tree | 1856ffac1a1dd60796adce8277b075f94fdedca1 /src/app_state.rs | |
| parent | e3b9124b85502d21b8d45abe8e4e7e4d3e08e7be (diff) | |
Add a disclaimer to the state file
Diffstat (limited to 'src/app_state.rs')
| -rw-r--r-- | src/app_state.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/app_state.rs b/src/app_state.rs index 9868781..09de2a3 100644 --- a/src/app_state.rs +++ b/src/app_state.rs @@ -53,7 +53,8 @@ impl AppState { } // See `Self::write` for more information about the file format. - let mut lines = self.file_buf.split(|c| *c == b'\n'); + let mut lines = self.file_buf.split(|c| *c == b'\n').skip(2); + let Some(current_exercise_name) = lines.next() else { return StateFileStatus::NotRead; }; @@ -300,14 +301,18 @@ impl AppState { // Write the state file. // The file's format is very simple: - // - The first line is the name of the current exercise. It must end with `\n` even if there - // are no done exercises. + // - The first line is a comment. // - The second line is an empty line. + // - The third line is the name of the current exercise. It must end with `\n` even if there + // are no done exercises. + // - The fourth line is an empty line. // - All remaining lines are the names of done exercises. fn write(&mut self) -> Result<()> { self.file_buf.clear(); self.file_buf + .extend_from_slice(b"DON'T EDIT THIS FILE!\n\n"); + self.file_buf .extend_from_slice(self.current_exercise().name.as_bytes()); self.file_buf.push(b'\n'); |
