mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-03-31 03:29:19 +00:00
Apply pedantic Clippy lints
This commit is contained in:
parent
0ffeb14402
commit
337f6b1521
@ -433,7 +433,7 @@ impl AppState {
|
|||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
|
|
||||||
let success = exercise.run_exercise(None, &slf.cmd_runner);
|
let success = exercise.run_exercise(None, &slf.cmd_runner);
|
||||||
let progress = match success {
|
let progress = match success {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ pub struct ExerciseInfo {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub skip_check_unsolved: bool,
|
pub skip_check_unsolved: bool,
|
||||||
}
|
}
|
||||||
#[inline(always)]
|
#[inline]
|
||||||
const fn default_true() -> bool {
|
const fn default_true() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -171,9 +171,9 @@ fn main() -> Result<ExitCode> {
|
|||||||
stdout.write_all(b"\n")?;
|
stdout.write_all(b"\n")?;
|
||||||
|
|
||||||
return Ok(ExitCode::FAILURE);
|
return Ok(ExitCode::FAILURE);
|
||||||
} else {
|
|
||||||
app_state.render_final_message(&mut stdout)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app_state.render_final_message(&mut stdout)?;
|
||||||
}
|
}
|
||||||
Some(Subcommands::Reset { name }) => {
|
Some(Subcommands::Reset { name }) => {
|
||||||
app_state.set_current_exercise_by_name(&name)?;
|
app_state.set_current_exercise_by_name(&name)?;
|
||||||
|
|||||||
@ -197,15 +197,15 @@ pub fn progress_bar<'a>(
|
|||||||
total: u16,
|
total: u16,
|
||||||
term_width: u16,
|
term_width: u16,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
debug_assert!(total <= 999);
|
|
||||||
debug_assert!(progress <= total);
|
|
||||||
|
|
||||||
const PREFIX: &[u8] = b"Progress: [";
|
const PREFIX: &[u8] = b"Progress: [";
|
||||||
const PREFIX_WIDTH: u16 = PREFIX.len() as u16;
|
const PREFIX_WIDTH: u16 = PREFIX.len() as u16;
|
||||||
const POSTFIX_WIDTH: u16 = "] xxx/xxx".len() as u16;
|
const POSTFIX_WIDTH: u16 = "] xxx/xxx".len() as u16;
|
||||||
const WRAPPER_WIDTH: u16 = PREFIX_WIDTH + POSTFIX_WIDTH;
|
const WRAPPER_WIDTH: u16 = PREFIX_WIDTH + POSTFIX_WIDTH;
|
||||||
const MIN_LINE_WIDTH: u16 = WRAPPER_WIDTH + 4;
|
const MIN_LINE_WIDTH: u16 = WRAPPER_WIDTH + 4;
|
||||||
|
|
||||||
|
debug_assert!(total <= 999);
|
||||||
|
debug_assert!(progress <= total);
|
||||||
|
|
||||||
if term_width < MIN_LINE_WIDTH {
|
if term_width < MIN_LINE_WIDTH {
|
||||||
writer.write_ascii(b"Progress: ")?;
|
writer.write_ascii(b"Progress: ")?;
|
||||||
// Integers are in ASCII.
|
// Integers are in ASCII.
|
||||||
|
|||||||
@ -60,7 +60,7 @@ impl<'a> WatchState<'a> {
|
|||||||
watch_event_sender,
|
watch_event_sender,
|
||||||
terminal_event_unpause_receiver,
|
terminal_event_unpause_receiver,
|
||||||
manual_run,
|
manual_run,
|
||||||
)
|
);
|
||||||
})
|
})
|
||||||
.context("Failed to spawn a thread to handle terminal events")?;
|
.context("Failed to spawn a thread to handle terminal events")?;
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ pub fn terminal_event_handler(
|
|||||||
// Pause input until quitting the confirmation prompt.
|
// Pause input until quitting the confirmation prompt.
|
||||||
if unpause_receiver.recv().is_err() {
|
if unpause_receiver.recv().is_err() {
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ pub fn terminal_event_handler(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(Event::FocusGained | Event::FocusLost | Event::Mouse(_)) => continue,
|
Ok(Event::FocusGained | Event::FocusLost | Event::Mouse(_)) => (),
|
||||||
Err(e) => break WatchEvent::TerminalEventErr(e),
|
Err(e) => break WatchEvent::TerminalEventErr(e),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user