summaryrefslogtreecommitdiff
path: root/src/verify.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-03-27 14:30:10 +0100
committermo8it <mo8it@proton.me>2024-03-27 14:30:10 +0100
commitb9d2756ce8093adb1a2e5a2ddc45bd07f1322f42 (patch)
tree200b890941938bf930a344a97ff3a9cfdcc3be45 /src/verify.rs
parente4520602f52935ff310534afc65160bcc5796a97 (diff)
parent07dec76f7c7f90d0768d2f5d9990e0b06019e0cd (diff)
Merge branch 'main' into toml
Diffstat (limited to 'src/verify.rs')
-rw-r--r--src/verify.rs35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/verify.rs b/src/verify.rs
index aee2afa..e2fa98f 100644
--- a/src/verify.rs
+++ b/src/verify.rs
@@ -24,7 +24,7 @@ pub fn verify<'a>(
.progress_chars("#>-"),
);
bar.set_position(num_done as u64);
- bar.set_message(format!("({:.1} %)", percentage));
+ bar.set_message(format!("({percentage:.1} %)"));
for exercise in exercises {
let compile_result = match exercise.mode {
@@ -37,7 +37,7 @@ pub fn verify<'a>(
}
percentage += 100.0 / total as f32;
bar.inc(1);
- bar.set_message(format!("({:.1} %)", percentage));
+ bar.set_message(format!("({percentage:.1} %)"));
if bar.position() == total as u64 {
println!(
"Progress: You completed {} / {} exercises ({:.1} %).",
@@ -51,6 +51,7 @@ pub fn verify<'a>(
Ok(())
}
+#[derive(PartialEq, Eq)]
enum RunMode {
Interactive,
NonInteractive,
@@ -124,7 +125,7 @@ fn compile_and_test(
if verbose {
println!("{}", output.stdout);
}
- if let RunMode::Interactive = run_mode {
+ if run_mode == RunMode::Interactive {
Ok(prompt_for_completion(exercise, None, success_hints))
} else {
Ok(true)
@@ -191,27 +192,25 @@ fn prompt_for_completion(
Mode::Test => "The code is compiling, and the tests pass!",
Mode::Clippy => clippy_success_msg,
};
- println!();
+
if no_emoji {
- println!("~*~ {success_msg} ~*~")
+ println!("\n~*~ {success_msg} ~*~\n");
} else {
- println!("šŸŽ‰ šŸŽ‰ {success_msg} šŸŽ‰ šŸŽ‰")
+ println!("\nšŸŽ‰ šŸŽ‰ {success_msg} šŸŽ‰ šŸŽ‰\n");
}
- println!();
if let Some(output) = prompt_output {
- println!("Output:");
- println!("{}", separator());
- println!("{output}");
- println!("{}", separator());
- println!();
+ println!(
+ "Output:\n{separator}\n{output}\n{separator}\n",
+ separator = separator(),
+ );
}
if success_hints {
- println!("Hints:");
- println!("{}", separator());
- println!("{}", exercise.hint);
- println!("{}", separator());
- println!();
+ println!(
+ "Hints:\n{separator}\n{}\n{separator}\n",
+ exercise.hint,
+ separator = separator(),
+ );
}
println!("You can keep working on this exercise,");
@@ -231,7 +230,7 @@ fn prompt_for_completion(
"{:>2} {} {}",
style(context_line.number).blue().bold(),
style("|").blue(),
- formatted_line
+ formatted_line,
);
}