Skip to content

Commit 6ec2e19

Browse files
committed
Apply Clippy lints
1 parent 295ad2e commit 6ec2e19

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

src/embedded.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ struct ExerciseFiles {
2020
}
2121

2222
fn create_dir_if_not_exists(path: &str) -> Result<()> {
23-
if let Err(e) = create_dir(path) {
24-
if e.kind() != io::ErrorKind::AlreadyExists {
25-
return Err(Error::from(e).context(format!("Failed to create the directory {path}")));
26-
}
23+
if let Err(e) = create_dir(path)
24+
&& e.kind() != io::ErrorKind::AlreadyExists
25+
{
26+
return Err(Error::from(e).context(format!("Failed to create the directory {path}")));
2727
}
2828

2929
Ok(())

src/exercise.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ fn run_bin(
4848

4949
let success = cmd_runner.run_debug_bin(bin_name, output.as_deref_mut())?;
5050

51-
if let Some(output) = output {
52-
if !success {
53-
// This output is important to show the user that something went wrong.
54-
// Otherwise, calling something like `exit(1)` in an exercise without further output
55-
// leaves the user confused about why the exercise isn't done yet.
56-
write_ansi(output, SetAttribute(Attribute::Bold));
57-
write_ansi(output, SetForegroundColor(Color::Red));
58-
output.extend_from_slice(b"The exercise didn't run successfully (nonzero exit code)");
59-
write_ansi(output, ResetColor);
60-
output.push(b'\n');
61-
}
51+
if let Some(output) = output
52+
&& !success
53+
{
54+
// This output is important to show the user that something went wrong.
55+
// Otherwise, calling something like `exit(1)` in an exercise without further output
56+
// leaves the user confused about why the exercise isn't done yet.
57+
write_ansi(output, SetAttribute(Attribute::Bold));
58+
write_ansi(output, SetForegroundColor(Color::Red));
59+
output.extend_from_slice(b"The exercise didn't run successfully (nonzero exit code)");
60+
write_ansi(output, ResetColor);
61+
output.push(b'\n');
6262
}
6363

6464
Ok(success)

src/list/state.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,21 @@ impl<'a> ListState<'a> {
118118
}
119119

120120
fn draw_exercise_name(&self, writer: &mut MaxLenWriter, exercise: &Exercise) -> io::Result<()> {
121-
if !self.search_query.is_empty() {
122-
if let Some((pre_highlight, highlight, post_highlight)) = exercise
121+
if !self.search_query.is_empty()
122+
&& let Some((pre_highlight, highlight, post_highlight)) = exercise
123123
.name
124124
.find(&self.search_query)
125125
.and_then(|ind| exercise.name.split_at_checked(ind))
126126
.and_then(|(pre_highlight, rest)| {
127127
rest.split_at_checked(self.search_query.len())
128128
.map(|x| (pre_highlight, x.0, x.1))
129129
})
130-
{
131-
writer.write_str(pre_highlight)?;
132-
writer.stdout.queue(SetForegroundColor(Color::Magenta))?;
133-
writer.write_str(highlight)?;
134-
writer.stdout.queue(SetForegroundColor(Color::Reset))?;
135-
return writer.write_str(post_highlight);
136-
}
130+
{
131+
writer.write_str(pre_highlight)?;
132+
writer.stdout.queue(SetForegroundColor(Color::Magenta))?;
133+
writer.write_str(highlight)?;
134+
writer.stdout.queue(SetForegroundColor(Color::Reset))?;
135+
return writer.write_str(post_highlight);
137136
}
138137

139138
writer.write_str(exercise.name)

0 commit comments

Comments
 (0)