From: Ruben Beltran del Rio Date: Sun, 26 Jan 2025 16:07:01 +0000 (+0100) Subject: Address clippy X-Git-Url: https://git.r.bdr.sh/rbdr/lyricli/commitdiff_plain/39ff8a112e043bd79220df71a74cf0549d75e06a?ds=sidebyside;hp=4064639d3c3e25760ef43781feca77332cfbe5eb Address clippy --- diff --git a/src/configuration.rs b/src/configuration.rs index 56d60d9..8d79eba 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use serde_json; +use serde_json::{from_str, to_string}; use std::env; use std::fs::{create_dir_all, write, File}; use std::io::{Read, Result}; @@ -65,12 +65,12 @@ impl Configuration { let mut config_file = File::open(&config_file_path).ok()?; let mut config_contents = String::new(); config_file.read_to_string(&mut config_contents).ok()?; - serde_json::from_str(&config_contents).ok()? + from_str(&config_contents).ok()? } fn write(configuration: &Configuration) -> Result<()> { let config_file_path = Configuration::file_path(); - if let Ok(serialized_configuration) = serde_json::to_string(&configuration) { + if let Ok(serialized_configuration) = to_string(&configuration) { write(&config_file_path, serialized_configuration)?; } Ok(()) diff --git a/src/lyrics_engine/genius.rs b/src/lyrics_engine/genius.rs index a8b0468..b33ff92 100644 --- a/src/lyrics_engine/genius.rs +++ b/src/lyrics_engine/genius.rs @@ -72,11 +72,9 @@ pub async fn get_lyrics(url: &str) -> Result { Element(element) => { if element.name() == "br" { lyrics.push('\n'); - } else { - if let Some(element_ref) = ElementRef::wrap(node) { - let text = element_ref.text().collect::>().join(""); - lyrics.push_str(&text); - } + } else if let Some(element_ref) = ElementRef::wrap(node) { + let text = element_ref.text().collect::>().join(""); + lyrics.push_str(&text); } } Text(text) => { diff --git a/src/main.rs b/src/main.rs index 96569d9..cab96a5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -98,7 +98,7 @@ async fn run() -> Result<()> { if let Some(artist) = arguments.artist { current_track = Track { name: arguments.track_name.unwrap_or("".to_string()), - artist: artist, + artist, }; } else { current_track =