diff --git a/src/db.rs b/src/db.rs index 57c0368..d48f27c 100644 --- a/src/db.rs +++ b/src/db.rs @@ -191,7 +191,7 @@ impl Database { let pod_id = stmt.query_row::(params![podcast.url], |row| row.get(0))?; let mut ep_ids = Vec::new(); for ep in podcast.episodes.iter().rev() { - let id = self.insert_episode(pod_id, &ep)?; + let id = self.insert_episode(pod_id, ep)?; let new_ep = NewEpisode { id: id, pod_id: pod_id, @@ -389,7 +389,7 @@ impl Database { } } None => { - let id = self.insert_episode(podcast_id, &new_ep)?; + let id = self.insert_episode(podcast_id, new_ep)?; let new_ep = NewEpisode { id: id, pod_id: podcast_id, @@ -520,7 +520,7 @@ impl Database { url: row.get("url")?, guid: row .get::<&str, Option>("guid")? - .unwrap_or("".to_string()), + .unwrap_or_else(|| "".to_string()), description: row.get("description")?, pubdate: convert_date(row.get("pubdate")), duration: row.get("duration")?, diff --git a/src/feeds.rs b/src/feeds.rs index 1e7ac2b..5e4482b 100644 --- a/src/feeds.rs +++ b/src/feeds.rs @@ -207,7 +207,7 @@ fn parse_episode_data(item: &Item) -> EpisodeNoId { fn duration_to_int(duration: Option<&str>) -> Option { match duration { Some(dur) => { - match RE_DURATION.captures(&dur) { + match RE_DURATION.captures(dur) { Some(cap) => { /* * Provided that the regex succeeds, we should have diff --git a/src/main.rs b/src/main.rs index b4c5546..f1388c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -371,7 +371,7 @@ fn import(db_path: &Path, config: Config, args: &clap::ArgMatches) -> Result<()> /// Exports all podcasts to OPML format, either printing to stdout or /// exporting to a file. fn export(db_path: &Path, args: &clap::ArgMatches) -> Result<()> { - let db_inst = Database::connect(&db_path)?; + let db_inst = Database::connect(db_path)?; let podcast_list = db_inst.get_podcasts()?; let opml = opml::export(podcast_list); diff --git a/src/main_controller.rs b/src/main_controller.rs index 8008930..053fb44 100644 --- a/src/main_controller.rs +++ b/src/main_controller.rs @@ -16,6 +16,7 @@ use crate::types::*; use crate::ui::{Ui, UiMsg}; /// Enum used for communicating with other threads. +#[allow(clippy::enum_variant_names)] #[derive(Debug)] pub enum MainMessage { UiUpdateMenus, @@ -52,7 +53,7 @@ impl MainController { let (tx_to_main, rx_to_main) = mpsc::channel(); // get connection to the database - let db_inst = Database::connect(&db_path)?; + let db_inst = Database::connect(db_path)?; // set up threadpool let threadpool = Threadpool::new(config.simultaneous_downloads); @@ -362,7 +363,7 @@ impl MainController { // if there is a local file, try to play that Some(path) => match path.to_str() { Some(p) => { - if play_file::execute(&self.config.play_command, &p).is_err() { + if play_file::execute(&self.config.play_command, p).is_err() { self.notif_to_ui( "Error: Could not play file. Check configuration.".to_string(), true, diff --git a/src/ui/colors.rs b/src/ui/colors.rs index de61b62..fde2e1a 100644 --- a/src/ui/colors.rs +++ b/src/ui/colors.rs @@ -110,7 +110,7 @@ impl AppColors { } return Err(anyhow!("Invalid color hex code")); } else if text.starts_with("rgb") || text.starts_with("RGB") { - #[allow(clippy::clippy::from_str_radix_10)] + #[allow(clippy::from_str_radix_10)] if let Some(cap) = RE_COLOR_RGB.captures(text) { return Ok(Color::Rgb { r: u8::from_str_radix(&cap[1], 10)?, diff --git a/src/ui/menu.rs b/src/ui/menu.rs index 400d245..5574af5 100644 --- a/src/ui/menu.rs +++ b/src/ui/menu.rs @@ -87,7 +87,7 @@ impl Menu { // for visible rows, print strings from list for i in self.start_row..self.panel.get_rows() { if let Some(elem_id) = order.get(self.get_menu_idx(i)) { - let elem = map.get(&elem_id).expect("Could not retrieve menu item."); + let elem = map.get(elem_id).expect("Could not retrieve menu item."); if i == self.selected || !elem.is_played() { let style = if !elem.is_played() { diff --git a/src/ui/notification.rs b/src/ui/notification.rs index d260cc8..a5a20d7 100644 --- a/src/ui/notification.rs +++ b/src/ui/notification.rs @@ -208,17 +208,15 @@ impl NotifWin { } } KeyCode::Char(c) => { + current_max_x += 1; + cursor_x += 1; if cursor_x < current_max_x { - current_max_x += 1; - cursor_x += 1; inputs.insert(cursor_idx, c); for i in inputs.chars().skip(cursor_idx) { execute!(io::stdout(), style::Print(i)).unwrap(); } execute!(io::stdout(), cursor::MoveTo(cursor_x, self.start_y)).unwrap(); } else { - current_max_x += 1; - cursor_x += 1; inputs.push(c); execute!(io::stdout(), style::Print(c)).unwrap(); }