mirror of
https://git.aramjonghu.dev/AramJonghu/rustlings.git
synced 2026-09-03 08:43:30 +02:00
Implement resetting
This commit is contained in:
+7
-1
@@ -10,7 +10,7 @@ use winnow::ascii::{space0, Caseless};
|
||||
use winnow::combinator::opt;
|
||||
use winnow::Parser;
|
||||
|
||||
use crate::embedded::EMBEDDED_FILES;
|
||||
use crate::embedded::{WriteStrategy, EMBEDDED_FILES};
|
||||
|
||||
// The number of context lines above and below a highlighted line.
|
||||
const CONTEXT: usize = 2;
|
||||
@@ -220,6 +220,12 @@ impl Exercise {
|
||||
pub fn looks_done(&self) -> Result<bool> {
|
||||
self.state().map(|state| state == State::Done)
|
||||
}
|
||||
|
||||
pub fn reset(&self) -> Result<()> {
|
||||
EMBEDDED_FILES
|
||||
.write_exercise_to_disk(&self.path, WriteStrategy::Overwrite)
|
||||
.with_context(|| format!("Failed to reset the exercise {self}"))
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Exercise {
|
||||
|
||||
Reference in New Issue
Block a user