From 7eaa68fcd906adcf320dced96779cafb1f8400e7 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 5 Mar 2023 20:32:12 +0100 Subject: Fix clippy warnings --- src/gui/question.rs | 11 +++++++---- src/model/difficulty.rs | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/question.rs b/src/gui/question.rs index 1c44272..c07b5f4 100644 --- a/src/gui/question.rs +++ b/src/gui/question.rs @@ -182,14 +182,17 @@ pub fn ask(terminal: &mut Terminal, title: &str, card: &Card) -> difficulty: selected, } => match key.code { KeyCode::Left => { - for d in relative_element(&card.state.difficulties(), &selected, -1).iter() + if let Some(difficulty) = + relative_element(&card.state.difficulties(), &selected, -1) { - state.answer = Answer::Difficulty { difficulty: *d } + state.answer = Answer::Difficulty { difficulty } } } KeyCode::Right => { - for d in relative_element(&card.state.difficulties(), &selected, 1).iter() { - state.answer = Answer::Difficulty { difficulty: *d } + if let Some(difficulty) = + relative_element(&card.state.difficulties(), &selected, 1) + { + state.answer = Answer::Difficulty { difficulty } } } KeyCode::Enter => { diff --git a/src/model/difficulty.rs b/src/model/difficulty.rs index ea5a9ce..727ce4b 100644 --- a/src/model/difficulty.rs +++ b/src/model/difficulty.rs @@ -1,4 +1,4 @@ -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Difficulty { Again, Hard, -- cgit v1.2.3