Pedantic clippy
This commit is contained in:
parent
7c2249ed08
commit
4e0195e132
@ -159,7 +159,7 @@ impl<'a> Column {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_task_state_from_curr_selected_task(&self) -> Option<TaskState<'a>> {
|
pub fn get_task_state_from_current(&self) -> Option<TaskState<'a>> {
|
||||||
self.get_selected_task().map(|t| TaskState {
|
self.get_selected_task().map(|t| TaskState {
|
||||||
title: TextArea::from(t.title.lines()),
|
title: TextArea::from(t.title.lines()),
|
||||||
description: TextArea::from(t.description.lines()),
|
description: TextArea::from(t.description.lines()),
|
||||||
|
@ -151,6 +151,7 @@ pub fn swap_task_order(conn: &mut Connection, task1: &Task, task2: &Task) {
|
|||||||
tx.commit().unwrap();
|
tx.commit().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// Panics if something goes wrong with the SQL
|
/// Panics if something goes wrong with the SQL
|
||||||
pub fn set_selected_column(conn: &Connection, column_id: usize) {
|
pub fn set_selected_column(conn: &Connection, column_id: usize) {
|
||||||
@ -161,19 +162,21 @@ pub fn set_selected_column(conn: &Connection, column_id: usize) {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// Panics if something goes wrong with the SQL
|
/// Panics if something goes wrong with the SQL
|
||||||
pub fn get_selected_column(conn: &Connection) -> usize {
|
pub fn get_selected_column(conn: &Connection) -> usize {
|
||||||
let mut stmt = conn
|
let mut stmt = conn
|
||||||
.prepare("select value from app_state where key = ?1")
|
.prepare("select value from app_state where key = ?1")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
stmt.query_row(&["selected_column"], |row| {
|
stmt.query_row(["selected_column"], |row| {
|
||||||
let value: String = row.get::<usize, String>(0).unwrap();
|
let value: String = row.get::<usize, String>(0).unwrap();
|
||||||
Ok(value.parse::<usize>().unwrap())
|
Ok(value.parse::<usize>().unwrap())
|
||||||
})
|
})
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// Panics if something goes wrong with the SQL
|
/// Panics if something goes wrong with the SQL
|
||||||
pub fn set_selected_task_for_column(conn: &Connection, task_idx: usize, column_id: i32) {
|
pub fn set_selected_task_for_column(conn: &Connection, task_idx: usize, column_id: i32) {
|
||||||
@ -183,6 +186,7 @@ pub fn set_selected_task_for_column(conn: &Connection, task_idx: usize, column_i
|
|||||||
stmt.execute((column_id, task_idx)).unwrap();
|
stmt.execute((column_id, task_idx)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// Panics if something goes wrong with the SQL
|
/// Panics if something goes wrong with the SQL
|
||||||
pub fn get_selected_task_for_column(conn: &Connection, column_id: i32) -> usize {
|
pub fn get_selected_task_for_column(conn: &Connection, column_id: i32) -> usize {
|
||||||
|
10
src/input.rs
10
src/input.rs
@ -146,9 +146,7 @@ pub fn handle_main(state: &mut State<'_>, key: event::KeyEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
KeyCode::Char('n') => state.task_edit_state = Some(TaskState::default()),
|
KeyCode::Char('n') => state.task_edit_state = Some(TaskState::default()),
|
||||||
KeyCode::Char('e') => {
|
KeyCode::Char('e') => state.task_edit_state = column.get_task_state_from_current(),
|
||||||
state.task_edit_state = column.get_task_state_from_curr_selected_task();
|
|
||||||
}
|
|
||||||
KeyCode::Char('D') => {
|
KeyCode::Char('D') => {
|
||||||
if !column.tasks.is_empty() {
|
if !column.tasks.is_empty() {
|
||||||
db::delete_task(&state.db_conn, column.get_selected_task().unwrap());
|
db::delete_task(&state.db_conn, column.get_selected_task().unwrap());
|
||||||
@ -173,9 +171,9 @@ pub fn handle_main(state: &mut State<'_>, key: event::KeyEvent) {
|
|||||||
/// Shouldn't really panic because there are checks to ensure we can unwrap safely
|
/// Shouldn't really panic because there are checks to ensure we can unwrap safely
|
||||||
pub fn handle(state: &mut State<'_>) -> Result<(), std::io::Error> {
|
pub fn handle(state: &mut State<'_>) -> Result<(), std::io::Error> {
|
||||||
if let Event::Key(key) = event::read()? {
|
if let Event::Key(key) = event::read()? {
|
||||||
if let Some(_) = state.task_edit_state {
|
if state.task_edit_state.is_some() {
|
||||||
let mut column = state.project.get_selected_column_mut();
|
let column = state.project.get_selected_column_mut();
|
||||||
handle_task_edit(&state.db_conn, &mut column, key, &mut state.task_edit_state);
|
handle_task_edit(&state.db_conn, column, key, &mut state.task_edit_state);
|
||||||
} else {
|
} else {
|
||||||
handle_main(state, key);
|
handle_main(state, key);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user