Format and apply Clippy suggestions

This commit is contained in:
Sijmen 2023-05-14 15:46:43 +02:00
parent 8e7a087e41
commit 138446e040
Signed by: vijfhoek
GPG Key ID: DAF7821E067D9C48
2 changed files with 8 additions and 7 deletions

View File

@ -1,4 +1,4 @@
use std::{path::Path, collections::HashMap};
use std::{collections::HashMap, path::Path};
use askama::Template;
use percent_encoding::percent_decode_str;
@ -176,7 +176,8 @@ struct UpdateQueueBody {
async fn post_queue_move(mut req: tide::Request<()>) -> tide::Result {
let body: UpdateQueueBody = req.body_json().await?;
let mut mpd = mpd::Mpd::connect().await?;
mpd.command(&format!("move {} {}", body.from, body.to)).await?;
mpd.command(&format!("move {} {}", body.from, body.to))
.await?;
Ok("".into())
}

View File

@ -246,7 +246,7 @@ impl Mpd {
}
}
#[allow(clippy::manual_map)]
pub async fn ls(&mut self, path: &str) -> anyhow::Result<Vec<Entry>> {
fn get_filename(path: &str) -> String {
std::path::Path::new(path)
@ -256,7 +256,7 @@ impl Mpd {
}
let result = self
.command(&format!("lsinfo \"{}\"", Self::escape_str(&path)))
.command(&format!("lsinfo \"{}\"", Self::escape_str(path)))
.await?
.into_hashmaps(&["file", "directory", "playlist"]);
@ -265,18 +265,18 @@ impl Mpd {
.flat_map(|prop| {
if let Some(file) = prop.get("file") {
Some(Entry::Song {
name: prop.get("Title").unwrap_or(&get_filename(&file)).clone(),
name: prop.get("Title").unwrap_or(&get_filename(file)).clone(),
artist: prop.get("Artist").unwrap_or(&String::new()).clone(),
path: file.to_string(),
})
} else if let Some(file) = prop.get("directory") {
Some(Entry::Directory {
name: get_filename(&file),
name: get_filename(file),
path: file.to_string(),
})
} else if let Some(file) = prop.get("playlist") {
Some(Entry::Playlist {
name: get_filename(&file),
name: get_filename(file),
path: file.to_string(),
})
} else {