1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-11-27 22:38:18 +02:00

Apply Clippy lints

This commit is contained in:
mo8it
2025-08-22 00:01:03 +02:00
parent 295ad2e4bd
commit 6ec2e194ae
3 changed files with 23 additions and 24 deletions

View File

@@ -20,11 +20,11 @@ struct ExerciseFiles {
}
fn create_dir_if_not_exists(path: &str) -> Result<()> {
if let Err(e) = create_dir(path) {
if e.kind() != io::ErrorKind::AlreadyExists {
if let Err(e) = create_dir(path)
&& e.kind() != io::ErrorKind::AlreadyExists
{
return Err(Error::from(e).context(format!("Failed to create the directory {path}")));
}
}
Ok(())
}

View File

@@ -48,8 +48,9 @@ fn run_bin(
let success = cmd_runner.run_debug_bin(bin_name, output.as_deref_mut())?;
if let Some(output) = output {
if !success {
if let Some(output) = output
&& !success
{
// This output is important to show the user that something went wrong.
// Otherwise, calling something like `exit(1)` in an exercise without further output
// leaves the user confused about why the exercise isn't done yet.
@@ -59,7 +60,6 @@ fn run_bin(
write_ansi(output, ResetColor);
output.push(b'\n');
}
}
Ok(success)
}

View File

@@ -118,8 +118,8 @@ impl<'a> ListState<'a> {
}
fn draw_exercise_name(&self, writer: &mut MaxLenWriter, exercise: &Exercise) -> io::Result<()> {
if !self.search_query.is_empty() {
if let Some((pre_highlight, highlight, post_highlight)) = exercise
if !self.search_query.is_empty()
&& let Some((pre_highlight, highlight, post_highlight)) = exercise
.name
.find(&self.search_query)
.and_then(|ind| exercise.name.split_at_checked(ind))
@@ -134,7 +134,6 @@ impl<'a> ListState<'a> {
writer.stdout.queue(SetForegroundColor(Color::Reset))?;
return writer.write_str(post_highlight);
}
}
writer.write_str(exercise.name)
}