v2.0.1 -> v2.0.2, appeased rust 1.66

This commit is contained in:
Xithrius 2022-12-15 16:38:59 -08:00
parent 82de6663b4
commit 76dd136b28
No known key found for this signature in database
GPG Key ID: DADE524BA67AA52E
11 changed files with 24 additions and 20 deletions

2
Cargo.lock generated
View File

@ -1492,7 +1492,7 @@ dependencies = [
[[package]]
name = "twitch-tui"
version = "2.0.1"
version = "2.0.2"
dependencies = [
"chrono",
"clap",

View File

@ -1,6 +1,6 @@
[package]
name = "twitch-tui"
version = "2.0.1"
version = "2.0.2"
authors = ["Xithrius <xithrius@gmail.com>"]
edition = "2021"
rust-version = "1.61.0"

View File

@ -111,7 +111,7 @@ impl Data {
};
let username_highlight_style = username_highlight.map_or_else(Style::default, |username| {
if Regex::new(format!("^.*{}.*$", username).as_str())
if Regex::new(format!("^.*{username}.*$").as_str())
.unwrap()
.is_match(&message)
{

View File

@ -39,7 +39,7 @@ impl Storage {
let enabled = match *item_key {
"channels" => config.channels,
"mentions" => config.mentions,
_ => panic!("Invalid storage key {}.", item_key),
_ => panic!("Invalid storage key {item_key}."),
};
items.insert(
@ -83,7 +83,7 @@ impl Storage {
}
}
} else {
panic!("Attempted to add value with key {} to JSON storage.", key);
panic!("Attempted to add value with key {key} to JSON storage.");
}
}
@ -93,7 +93,7 @@ impl Storage {
.get(&key.to_string())
.map_or_else(Vec::new, |item| item.content.clone())
} else {
panic!("Attempted to get key {} from JSON storage.", key);
panic!("Attempted to get key {key} from JSON storage.");
}
}
}

View File

@ -91,7 +91,7 @@ impl Events {
_ => Key::Null,
};
if let Err(err) = tx.send(Event::Input(key)).await {
eprintln!("Keyboard input error: {}", err);
eprintln!("Keyboard input error: {err}");
return;
}
}
@ -103,7 +103,7 @@ impl Events {
};
if let Err(err) = tx.send(Event::Input(key)).await {
eprintln!("Mouse input error: {}", err);
eprintln!("Mouse input error: {err}");
return;
}
}
@ -113,7 +113,7 @@ impl Events {
if last_tick.elapsed() >= config.tick_rate {
if let Err(err) = tx.send(Event::Tick).await {
eprintln!("{}", err);
eprintln!("{err}");
return;
}
last_tick = Instant::now();

View File

@ -7,7 +7,8 @@
clippy::struct_excessive_bools,
clippy::unused_self,
clippy::future_not_send,
clippy::needless_pass_by_value
clippy::needless_pass_by_value,
clippy::suboptimal_flops
)]
use clap::Parser;

View File

@ -54,7 +54,7 @@ pub async fn client_stream_reconnect(
}
_ => {
tx.send(data_builder.system(
format!("Attempting to reconnect due to fatal error: {:?}", err).to_string(),
format!("Attempting to reconnect due to fatal error: {err:?}").to_string(),
))
.await
.unwrap();

View File

@ -76,15 +76,15 @@ pub async fn twitch_irc(
.unwrap();
}
TwitchAction::Join(channel) => {
debug!("Switching to channel {}", channel);
debug!("Switching to channel {channel}");
let channel_list = format!("#{}", channel);
let channel_list = format!("#{channel}");
// Leave previous channel
if let Err(err) = sender.send_part(current_channel) {
tx.send(data_builder.twitch(err.to_string())).await.unwrap();
} else {
tx.send(data_builder.twitch(format!("Joined {}", channel_list))).await.unwrap();
tx.send(data_builder.twitch(format!("Joined {channel_list}"))).await.unwrap();
}
// Join specified channel

View File

@ -37,7 +37,7 @@ pub fn render_chat_box<T: Backend>(window: WindowAttributes<T>, mention_suggesti
let default_suggestion = possible_suggestion.clone();
possible_suggestion.map_or(default_suggestion, |s| Some(format!("/{}", s)))
possible_suggestion.map_or(default_suggestion, |s| Some(format!("/{s}")))
}
'@' => {
let possible_suggestion =
@ -45,7 +45,7 @@ pub fn render_chat_box<T: Backend>(window: WindowAttributes<T>, mention_suggesti
let default_suggestion = possible_suggestion.clone();
possible_suggestion.map_or(default_suggestion, |s| Some(format!("@{}", s)))
possible_suggestion.map_or(default_suggestion, |s| Some(format!("@{s}")))
}
_ => None,
})

View File

@ -13,7 +13,7 @@ pub fn centered_popup(size: Rect, terminal_height: u16) -> Rect {
.direction(Direction::Vertical)
.constraints(
[
Constraint::Length((terminal_height / 2) as u16 - 6),
Constraint::Length((terminal_height / 2) - 6),
Constraint::Length(3),
Constraint::Min(0),
]

View File

@ -22,11 +22,14 @@ pub fn align_text(text: &str, alignment: Alignment, maximum_length: u16) -> Stri
}
match alignment {
Alignment::Right => format!("{}{}", " ".repeat(maximum_length as usize - dw), text),
Alignment::Right => {
let spacing = " ".repeat(maximum_length as usize - dw);
format!("{spacing}{text}")
}
Alignment::Center => {
let side_spaces =
" ".repeat(((maximum_length / 2) - (((dw / 2) as f32).floor() as u16)) as usize);
format!("{}{}{}", side_spaces, text, side_spaces)
format!("{side_spaces}{text}{side_spaces}")
}
Alignment::Left => text.to_string(),
}
@ -83,7 +86,7 @@ pub fn title_spans(contents: Vec<TitleStyle>, style: Style) -> Vec<Span> {
TitleStyle::Combined(title, value) => vec![
first_bracket,
Span::styled((*title).to_string(), style),
Span::raw(format!(": {} ]", value)),
Span::raw(format!(": {value} ]")),
],
TitleStyle::Single(value) => vec![
first_bracket,