mirror of
https://github.com/lucaspalomodevelop/binbreak.git
synced 2026-03-13 00:07:28 +00:00
run clippy --fix
This commit is contained in:
parent
69de23c76b
commit
9b56dee062
@ -127,8 +127,9 @@ fn render_start_screen(state: &mut StartMenuState, area: Rect, buf: &mut Buffer)
|
||||
}
|
||||
|
||||
fn handle_crossterm_events(app_state: &mut AppState) -> color_eyre::Result<()> {
|
||||
if let Event::Key(key) = event::read()? {
|
||||
if key.kind == KeyEventKind::Press {
|
||||
if let Event::Key(key) = event::read()?
|
||||
&& key.kind == KeyEventKind::Press
|
||||
{
|
||||
match key.code {
|
||||
// global exit via Ctrl+C
|
||||
KeyCode::Char('c') | KeyCode::Char('C')
|
||||
@ -153,7 +154,6 @@ fn handle_crossterm_events(app_state: &mut AppState) -> color_eyre::Result<()> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@ -168,7 +168,7 @@ impl WidgetRef for BinaryNumbersPuzzle {
|
||||
Block::bordered().border_type(border_type).fg(border_color).render(area, buf);
|
||||
|
||||
let suggestion_str = format!("{suggestion}");
|
||||
Paragraph::new(format!("{}", suggestion_str))
|
||||
Paragraph::new(suggestion_str.to_string())
|
||||
.white()
|
||||
.when(show_correct_number && is_correct_number, |p| p.light_green().underlined())
|
||||
.alignment(Center)
|
||||
@ -241,7 +241,7 @@ impl WidgetRef for BinaryNumbersPuzzle {
|
||||
|
||||
Block::bordered().dark_gray().render(result_area, buf);
|
||||
|
||||
let instruction_spans: Vec<Span> = vec![
|
||||
let instruction_spans: Vec<Span> = [
|
||||
hotkey_span("Left Right", "select "),
|
||||
hotkey_span("Enter", "confirm "),
|
||||
hotkey_span("S", "skip "),
|
||||
@ -293,7 +293,7 @@ impl MainScreenWidget for BinaryNumbersGame {
|
||||
self.refresh_stats_snapshot();
|
||||
}
|
||||
|
||||
fn handle_input(&mut self, input: KeyEvent) -> () { self.handle_game_input(input); }
|
||||
fn handle_input(&mut self, input: KeyEvent) { self.handle_game_input(input); }
|
||||
fn is_exit_intended(&self) -> bool { self.exit_intended }
|
||||
}
|
||||
|
||||
@ -632,8 +632,7 @@ impl Widget for &mut BinaryNumbersGame {
|
||||
|
||||
// Simple ASCII gauge renderer to avoid variable glyph heights from Unicode block elements
|
||||
fn render_ascii_gauge(area: Rect, buf: &mut Buffer, ratio: f64, color: Color) {
|
||||
let clamped = if ratio < 0.0 { 0.0 } else if ratio > 1.0 { 1.0 } else { ratio };
|
||||
let fill_width = ((area.width as f64) * clamped).round().min(area.width as f64) as u16;
|
||||
let fill_width = ((area.width as f64) * ratio.clamp(0.0, 1.0)).round().min(area.width as f64) as u16;
|
||||
if area.height == 0 { return; }
|
||||
for x in 0..area.width {
|
||||
let filled = x < fill_width;
|
||||
@ -664,14 +663,15 @@ impl HighScores {
|
||||
let mut contents = String::new();
|
||||
if file.read_to_string(&mut contents).is_ok() {
|
||||
for line in contents.lines() {
|
||||
if let Some((k,v)) = line.split_once('=') {
|
||||
if let (Ok(bits), Ok(score)) = (k.trim().parse::<u32>(), v.trim().parse::<u32>()) {
|
||||
if let Some((k,v)) = line.split_once('=')
|
||||
&& let Ok(bits) = k.trim().parse::<u32>()
|
||||
&& let Ok(score) = v.trim().parse::<u32>()
|
||||
{
|
||||
hs.scores.insert(bits, score);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hs
|
||||
}
|
||||
|
||||
|
||||
@ -89,8 +89,8 @@ impl Widget for AsciiArtWidget {
|
||||
|
||||
pub fn center(area: Rect, horizontal: Constraint) -> Rect {
|
||||
let [area] = Layout::horizontal([horizontal]).flex(Flex::Center).areas(area);
|
||||
let area = vertically_center(area);
|
||||
area
|
||||
|
||||
vertically_center(area)
|
||||
}
|
||||
|
||||
pub fn vertically_center(area: Rect) -> Rect {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user