Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Cargo.lock & apply clippy suggestions #1046

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,153 changes: 641 additions & 512 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ impl App {
self
.user
.to_owned()
.and_then(|user| Country::from_str(&user.country.unwrap_or_else(|| "".to_string())).ok())
.and_then(|user| Country::from_str(&user.country.unwrap_or_default()).ok())
}

pub fn calculate_help_menu_offset(&mut self) {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/cli_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl<'a> CliApp<'a> {

pub async fn seek(&mut self, seconds_str: String) -> Result<()> {
let seconds = match seconds_str.parse::<i32>() {
Ok(s) => s.abs() as u32,
Ok(s) => s.unsigned_abs(),
Err(_) => return Err(anyhow!("failed to convert seconds to i32")),
};

Expand All @@ -296,7 +296,7 @@ impl<'a> CliApp<'a> {
PlayingItem::Episode(episode) => episode.duration_ms,
};

(*ms as u32, duration)
(*ms, duration)
} else {
return Err(anyhow!("no context available"));
}
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl ClientConfig {
std::io::ErrorKind::InvalidInput,
format!("invalid length: {} (must be {})", key.len(), EXPECTED_LEN,),
)))
} else if !key.chars().all(|c| c.is_digit(16)) {
} else if !key.chars().all(|c| c.is_ascii_hexdigit()) {
Err(Error::from(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"invalid character found (must be hex digits)",
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn spotify_resource_id(base: &str, uri: &str, sep: &str, resource_type: &str) ->
let id_string_with_query_params = uri.trim_start_matches(&uri_prefix);
let query_idx = id_string_with_query_params
.find('?')
.unwrap_or_else(|| id_string_with_query_params.len());
.unwrap_or(id_string_with_query_params.len());
let id_string = id_string_with_query_params[0..query_idx].to_string();
// If the lengths aren't equal, we must have found a match.
let matched = id_string_with_query_params.len() != uri.len() && id_string.len() != uri.len();
Expand Down
14 changes: 7 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,24 +319,24 @@ async fn start_ui(user_config: UserConfig, app: &Arc<Mutex<App>>) -> Result<()>
};

let current_route = app.get_current_route();
terminal.draw(|mut f| match current_route.active_block {
terminal.draw(|f| match current_route.active_block {
ActiveBlock::HelpMenu => {
ui::draw_help_menu(&mut f, &app);
ui::draw_help_menu(f, &app);
}
ActiveBlock::Error => {
ui::draw_error_screen(&mut f, &app);
ui::draw_error_screen(f, &app);
}
ActiveBlock::SelectDevice => {
ui::draw_device_list(&mut f, &app);
ui::draw_device_list(f, &app);
}
ActiveBlock::Analysis => {
ui::audio_analysis::draw(&mut f, &app);
ui::audio_analysis::draw(f, &app);
}
ActiveBlock::BasicView => {
ui::draw_basic_view(&mut f, &app);
ui::draw_basic_view(f, &app);
}
_ => {
ui::draw_main_layout(&mut f, &app);
ui::draw_main_layout(f, &app);
}
})?;

Expand Down
18 changes: 9 additions & 9 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ where
);

let input_string: String = app.input.iter().collect();
let lines = Text::from((&input_string).as_str());
let lines = Text::from(input_string.as_str());
let input = Paragraph::new(lines).block(
Block::default()
.borders(Borders::ALL)
Expand Down Expand Up @@ -392,15 +392,15 @@ where
PlayingItem::Episode(episode) => Some(episode.id),
})
})
.unwrap_or_else(|| "".to_string());
.unwrap_or_default();

let songs = match &app.search_results.tracks {
Some(tracks) => tracks
.items
.iter()
.map(|item| {
let mut song_name = "".to_string();
let id = item.clone().id.unwrap_or_else(|| "".to_string());
let id = item.clone().id.unwrap_or_default();
if currently_playing_id == id {
song_name += "▶ "
}
Expand Down Expand Up @@ -692,7 +692,7 @@ where
.items
.iter()
.map(|item| TableItem {
id: item.id.clone().unwrap_or_else(|| "".to_string()),
id: item.id.clone().unwrap_or_default(),
format: vec![
"".to_string(),
item.track_number.to_string(),
Expand All @@ -718,7 +718,7 @@ where
.items
.iter()
.map(|item| TableItem {
id: item.id.clone().unwrap_or_else(|| "".to_string()),
id: item.id.clone().unwrap_or_default(),
format: vec![
"".to_string(),
item.track_number.to_string(),
Expand Down Expand Up @@ -798,7 +798,7 @@ where
.tracks
.iter()
.map(|item| TableItem {
id: item.id.clone().unwrap_or_else(|| "".to_string()),
id: item.id.clone().unwrap_or_default(),
format: vec![
"".to_string(),
item.name.to_owned(),
Expand Down Expand Up @@ -877,7 +877,7 @@ where
.tracks
.iter()
.map(|item| TableItem {
id: item.id.clone().unwrap_or_else(|| "".to_string()),
id: item.id.clone().unwrap_or_default(),
format: vec![
"".to_string(),
item.name.to_owned(),
Expand Down Expand Up @@ -988,7 +988,7 @@ where

let (item_id, name, duration_ms) = match track_item {
PlayingItem::Track(track) => (
track.id.to_owned().unwrap_or_else(|| "".to_string()),
track.id.to_owned().unwrap_or_default(),
track.name.to_owned(),
track.duration_ms,
),
Expand Down Expand Up @@ -1612,7 +1612,7 @@ where
.items
.iter()
.map(|item| TableItem {
id: item.track.id.clone().unwrap_or_else(|| "".to_string()),
id: item.track.id.clone().unwrap_or_default(),
format: vec![
"".to_string(),
item.track.name.to_owned(),
Expand Down
2 changes: 1 addition & 1 deletion src/user_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ fn parse_theme_item(theme_item: &str) -> Result<Color> {
"White" => Color::White,
_ => {
let colors = theme_item.split(',').collect::<Vec<&str>>();
if let (Some(r), Some(g), Some(b)) = (colors.get(0), colors.get(1), colors.get(2)) {
if let (Some(r), Some(g), Some(b)) = (colors.first(), colors.get(1), colors.get(2)) {
Color::Rgb(
r.trim().parse::<u8>()?,
g.trim().parse::<u8>()?,
Expand Down