diff --git a/src/embedded.rs b/src/embedded.rs index 88c1fb01..61a5f581 100644 --- a/src/embedded.rs +++ b/src/embedded.rs @@ -20,10 +20,10 @@ struct ExerciseFiles { } fn create_dir_if_not_exists(path: &str) -> Result<()> { - if let Err(e) = create_dir(path) { - if e.kind() != io::ErrorKind::AlreadyExists { - return Err(Error::from(e).context(format!("Failed to create the directory {path}"))); - } + 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(()) diff --git a/src/exercise.rs b/src/exercise.rs index 6f517bee..a0596b5b 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -48,17 +48,17 @@ fn run_bin( let success = cmd_runner.run_debug_bin(bin_name, output.as_deref_mut())?; - if let Some(output) = output { - if !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. - write_ansi(output, SetAttribute(Attribute::Bold)); - write_ansi(output, SetForegroundColor(Color::Red)); - output.extend_from_slice(b"The exercise didn't run successfully (nonzero exit code)"); - write_ansi(output, ResetColor); - output.push(b'\n'); - } + 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. + write_ansi(output, SetAttribute(Attribute::Bold)); + write_ansi(output, SetForegroundColor(Color::Red)); + output.extend_from_slice(b"The exercise didn't run successfully (nonzero exit code)"); + write_ansi(output, ResetColor); + output.push(b'\n'); } Ok(success) diff --git a/src/list/state.rs b/src/list/state.rs index 50d06be9..4fd1301d 100644 --- a/src/list/state.rs +++ b/src/list/state.rs @@ -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)) @@ -127,13 +127,12 @@ impl<'a> ListState<'a> { rest.split_at_checked(self.search_query.len()) .map(|x| (pre_highlight, x.0, x.1)) }) - { - writer.write_str(pre_highlight)?; - writer.stdout.queue(SetForegroundColor(Color::Magenta))?; - writer.write_str(highlight)?; - writer.stdout.queue(SetForegroundColor(Color::Reset))?; - return writer.write_str(post_highlight); - } + { + writer.write_str(pre_highlight)?; + writer.stdout.queue(SetForegroundColor(Color::Magenta))?; + writer.write_str(highlight)?; + writer.stdout.queue(SetForegroundColor(Color::Reset))?; + return writer.write_str(post_highlight); } writer.write_str(exercise.name)