summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-12-22 03:32:32 -0500
committerJesse Luehrs <doy@tozt.net>2018-12-22 03:32:32 -0500
commitbb860c9777d971a72e685148c6c1b2cdc13b3e0b (patch)
tree757a16d36076002d05ee9c9a12bfa594f351eb2f
parent144a829d82db142d1f6ae76adf49dddd77751428 (diff)
downloadlastfm-query-bb860c9777d971a72e685148c6c1b2cdc13b3e0b.tar.gz
lastfm-query-bb860c9777d971a72e685148c6c1b2cdc13b3e0b.zip
cargo clippy
-rw-r--r--src/cmd/mod.rs2
-rw-r--r--src/cmd/sql.rs2
-rw-r--r--src/cmd/sync.rs8
-rw-r--r--src/db.rs14
-rw-r--r--src/lastfm/mod.rs6
5 files changed, 16 insertions, 16 deletions
diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs
index 68ae2fb..e793b55 100644
--- a/src/cmd/mod.rs
+++ b/src/cmd/mod.rs
@@ -2,7 +2,7 @@ mod recommend;
mod sql;
mod sync;
-const _DUMMY_DEPENDENCY: &'static str = include_str!("../../Cargo.toml");
+const _DUMMY_DEPENDENCY: &str = include_str!("../../Cargo.toml");
trait Command {
fn run(&self) -> failure::Fallible<()>;
diff --git a/src/cmd/sql.rs b/src/cmd/sql.rs
index 404c97e..bf4b768 100644
--- a/src/cmd/sql.rs
+++ b/src/cmd/sql.rs
@@ -78,7 +78,7 @@ fn format_value(v: &rusqlite::types::ValueRef) -> String {
rusqlite::types::ValueRef::Null => "null".to_string(),
rusqlite::types::ValueRef::Integer(i) => format!("{}", i),
rusqlite::types::ValueRef::Real(f) => format!("{}", f),
- rusqlite::types::ValueRef::Text(s) => format!("{}", s),
+ rusqlite::types::ValueRef::Text(s) => s.to_string(),
rusqlite::types::ValueRef::Blob(b) => format!("{:?}", b),
}
}
diff --git a/src/cmd/sync.rs b/src/cmd/sync.rs
index b6019c4..2d5b25b 100644
--- a/src/cmd/sync.rs
+++ b/src/cmd/sync.rs
@@ -35,8 +35,8 @@ impl super::Command for Command {
let to_fetch = lastfm.track_count(from)?;
if to_fetch > 0 {
- let bar = indicatif::ProgressBar::new(to_fetch);
- bar.set_style(
+ let pbar = indicatif::ProgressBar::new(to_fetch);
+ pbar.set_style(
indicatif::ProgressStyle::default_bar()
.progress_chars("=> ")
.template(
@@ -45,9 +45,9 @@ impl super::Command for Command {
),
);
- db.insert_tracks(bar.wrap_iter(lastfm.tracks(from)))?;
+ db.insert_tracks(pbar.wrap_iter(lastfm.tracks(from)))?;
- bar.finish_with_message("done");
+ pbar.finish_with_message("done");
}
Ok(())
diff --git a/src/db.rs b/src/db.rs
index 27737cb..4afa3df 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -2,7 +2,7 @@ use lastfm;
use failure::Fail;
-const SCHEMA: &'static str = "
+const SCHEMA: &str = "
CREATE TABLE `tracks` (
artist varchar(1024) NOT NULL,
album varchar(1024) DEFAULT NULL,
@@ -50,7 +50,7 @@ impl DB {
Self::create(path)?
};
- return Ok(DB { conn });
+ Ok(DB { conn })
}
fn create<P: AsRef<std::path::Path>>(
@@ -149,7 +149,7 @@ impl DB {
FROM {}
)
",
- timewindow_table(&exclude)
+ timewindow_table(exclude)
)
} else {
"".to_string()
@@ -169,7 +169,7 @@ impl DB {
{}
LIMIT {}
",
- timewindow_table(&include),
+ timewindow_table(include),
exclude,
order,
count
@@ -202,7 +202,7 @@ impl DB {
WHERE artist = ?
)
",
- timewindow_table(&exclude)
+ timewindow_table(exclude)
)
} else {
"".to_string()
@@ -223,7 +223,7 @@ impl DB {
{}
LIMIT 1
",
- timewindow_table(&include),
+ timewindow_table(include),
exclude,
order
);
@@ -248,7 +248,7 @@ pub fn parse_timewindow(s: &str) -> TimeWindow {
}
}
-fn timewindow_table(tw: &TimeWindow) -> String {
+fn timewindow_table(tw: TimeWindow) -> String {
match tw {
TimeWindow::All => "tracks".to_string(),
TimeWindow::Yearly => "yearly_tracks".to_string(),
diff --git a/src/lastfm/mod.rs b/src/lastfm/mod.rs
index ed6e81b..0704e5a 100644
--- a/src/lastfm/mod.rs
+++ b/src/lastfm/mod.rs
@@ -5,7 +5,7 @@ use std::io::{Read, Write};
mod api_types;
-const API_ROOT: &'static str = "https://ws.audioscrobbler.com/2.0/";
+const API_ROOT: &str = "https://ws.audioscrobbler.com/2.0/";
pub struct LastFMClient {
client: reqwest::Client,
@@ -38,7 +38,7 @@ impl<'a> Tracks<'a> {
}
fn get_next_page(&mut self) -> failure::Fallible<()> {
- if !self.page.is_some() {
+ if self.page.is_none() {
self.page = Some(self.client.get_total_pages(self.from)?);
}
let page = self.page.unwrap();
@@ -90,7 +90,7 @@ impl<'a> Iterator for Tracks<'a> {
type Item = Track;
fn next(&mut self) -> Option<Track> {
- if self.buf.len() == 0 {
+ if self.buf.is_empty() {
let result = self.get_next_page();
if result.is_err() {
return None;