mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-02-12 04:39:19 +00:00
Merge 2e1b42a87fc01601a5c237af64cc0763688c63a2 into 87ac600b7c050538b1622084ea7c356b8a1d02bc
This commit is contained in:
commit
3000d47c98
15
src/main.rs
15
src/main.rs
@ -176,9 +176,18 @@ fn main() -> Result<ExitCode> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Subcommands::Reset { name }) => {
|
Some(Subcommands::Reset { name }) => {
|
||||||
app_state.set_current_exercise_by_name(&name)?;
|
if name == "all" {
|
||||||
let exercise_path = app_state.reset_current_exercise()?;
|
let n_exercises = app_state.exercises().len();
|
||||||
println!("The exercise {exercise_path} has been reset");
|
for ind in 0..n_exercises {
|
||||||
|
app_state.reset_exercise_by_ind(ind)?;
|
||||||
|
}
|
||||||
|
app_state.set_current_exercise_ind(0)?;
|
||||||
|
println!("All exercises have been reset");
|
||||||
|
} else {
|
||||||
|
app_state.set_current_exercise_by_name(&name)?;
|
||||||
|
let exercise_path = app_state.reset_current_exercise()?;
|
||||||
|
println!("The exercise {exercise_path} has been reset");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some(Subcommands::Hint { name }) => {
|
Some(Subcommands::Hint { name }) => {
|
||||||
if let Some(name) = name {
|
if let Some(name) = name {
|
||||||
|
|||||||
@ -143,6 +143,15 @@ fn reset_without_exercise_name() {
|
|||||||
Cmd::default().args(&["reset"]).fail();
|
Cmd::default().args(&["reset"]).fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reset_all() {
|
||||||
|
Cmd::default()
|
||||||
|
.current_dir("tests/test_exercises")
|
||||||
|
.args(&["reset", "all"])
|
||||||
|
.output(PartialStdout("All exercises have been reset"))
|
||||||
|
.success();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hint() {
|
fn hint() {
|
||||||
Cmd::default()
|
Cmd::default()
|
||||||
|
|||||||
@ -43,6 +43,13 @@ The list allows you to…
|
|||||||
|
|
||||||
See the footer of the list for all possible keys.
|
See the footer of the list for all possible keys.
|
||||||
|
|
||||||
|
## Resetting Exercises
|
||||||
|
|
||||||
|
You can reset an exercise to its original state using the `reset` command:
|
||||||
|
|
||||||
|
- `rustlings reset <exercise_name>`: Reset a single exercise
|
||||||
|
- `rustlings reset all`: Reset all exercises
|
||||||
|
|
||||||
## Questions?
|
## Questions?
|
||||||
|
|
||||||
If you need any help while doing the exercises and the builtin hints aren't helpful, feel free to ask in the [_Q&A_ discussions](https://github.com/rust-lang/rustlings/discussions/categories/q-a?discussions_q=) if your question isn't answered there 💡
|
If you need any help while doing the exercises and the builtin hints aren't helpful, feel free to ask in the [_Q&A_ discussions](https://github.com/rust-lang/rustlings/discussions/categories/q-a?discussions_q=) if your question isn't answered there 💡
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user