mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-10 12:49:18 +00:00
Format better and remove unnecessary borrows
This commit is contained in:
parent
374f83dd59
commit
a44275541a
@ -162,7 +162,7 @@ path = "{}.rs""#,
|
|||||||
|
|
||||||
if cmd.status.success() {
|
if cmd.status.success() {
|
||||||
Ok(CompiledExercise {
|
Ok(CompiledExercise {
|
||||||
exercise: &self,
|
exercise: self,
|
||||||
_handle: FileHandle,
|
_handle: FileHandle,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -203,7 +203,7 @@ fn main() {
|
|||||||
Subcommands::Run(subargs) => {
|
Subcommands::Run(subargs) => {
|
||||||
let exercise = find_exercise(&subargs.name, &exercises);
|
let exercise = find_exercise(&subargs.name, &exercises);
|
||||||
|
|
||||||
run(&exercise, verbose).unwrap_or_else(|_| std::process::exit(1));
|
run(exercise, verbose).unwrap_or_else(|_| std::process::exit(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
Subcommands::Hint(subargs) => {
|
Subcommands::Hint(subargs) => {
|
||||||
|
|||||||
@ -14,9 +14,9 @@ pub fn verify<'a>(
|
|||||||
) -> Result<(), &'a Exercise> {
|
) -> Result<(), &'a Exercise> {
|
||||||
for exercise in start_at {
|
for exercise in start_at {
|
||||||
let compile_result = match exercise.mode {
|
let compile_result = match exercise.mode {
|
||||||
Mode::Test => compile_and_test(&exercise, RunMode::Interactive, verbose),
|
Mode::Test => compile_and_test(exercise, RunMode::Interactive, verbose),
|
||||||
Mode::Compile => compile_and_run_interactively(&exercise),
|
Mode::Compile => compile_and_run_interactively(exercise),
|
||||||
Mode::Clippy => compile_only(&exercise),
|
Mode::Clippy => compile_only(exercise),
|
||||||
};
|
};
|
||||||
if !compile_result.unwrap_or(false) {
|
if !compile_result.unwrap_or(false) {
|
||||||
return Err(exercise);
|
return Err(exercise);
|
||||||
@ -42,11 +42,11 @@ fn compile_only(exercise: &Exercise) -> Result<bool, ()> {
|
|||||||
progress_bar.set_message(format!("Compiling {}...", exercise).as_str());
|
progress_bar.set_message(format!("Compiling {}...", exercise).as_str());
|
||||||
progress_bar.enable_steady_tick(100);
|
progress_bar.enable_steady_tick(100);
|
||||||
|
|
||||||
let _ = compile(&exercise, &progress_bar)?;
|
let _ = compile(exercise, &progress_bar)?;
|
||||||
progress_bar.finish_and_clear();
|
progress_bar.finish_and_clear();
|
||||||
|
|
||||||
success!("Successfully compiled {}!", exercise);
|
success!("Successfully compiled {}!", exercise);
|
||||||
Ok(prompt_for_completion(&exercise, None))
|
Ok(prompt_for_completion(exercise, None))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile the given Exercise and run the resulting binary in an interactive mode
|
// Compile the given Exercise and run the resulting binary in an interactive mode
|
||||||
@ -55,7 +55,7 @@ fn compile_and_run_interactively(exercise: &Exercise) -> Result<bool, ()> {
|
|||||||
progress_bar.set_message(format!("Compiling {}...", exercise).as_str());
|
progress_bar.set_message(format!("Compiling {}...", exercise).as_str());
|
||||||
progress_bar.enable_steady_tick(100);
|
progress_bar.enable_steady_tick(100);
|
||||||
|
|
||||||
let compilation = compile(&exercise, &progress_bar)?;
|
let compilation = compile(exercise, &progress_bar)?;
|
||||||
|
|
||||||
progress_bar.set_message(format!("Running {}...", exercise).as_str());
|
progress_bar.set_message(format!("Running {}...", exercise).as_str());
|
||||||
let result = compilation.run();
|
let result = compilation.run();
|
||||||
@ -73,7 +73,7 @@ fn compile_and_run_interactively(exercise: &Exercise) -> Result<bool, ()> {
|
|||||||
|
|
||||||
success!("Successfully ran {}!", exercise);
|
success!("Successfully ran {}!", exercise);
|
||||||
|
|
||||||
Ok(prompt_for_completion(&exercise, Some(output.stdout)))
|
Ok(prompt_for_completion(exercise, Some(output.stdout)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile the given Exercise as a test harness and display
|
// Compile the given Exercise as a test harness and display
|
||||||
@ -94,7 +94,7 @@ fn compile_and_test(exercise: &Exercise, run_mode: RunMode, verbose: bool) -> Re
|
|||||||
}
|
}
|
||||||
success!("Successfully tested {}", &exercise);
|
success!("Successfully tested {}", &exercise);
|
||||||
if let RunMode::Interactive = run_mode {
|
if let RunMode::Interactive = run_mode {
|
||||||
Ok(prompt_for_completion(&exercise, None))
|
Ok(prompt_for_completion(exercise, None))
|
||||||
} else {
|
} else {
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user