Skip to content

Commit 2536715

Browse files
committed
chore: fixed some warnings
1 parent 03c53b7 commit 2536715

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

anyrun/src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ fn handle_matches(plugin_view: PluginView, runtime_data: &RuntimeData, matches:
816816
}
817817
}
818818

819-
if let Some((row, view)) = combined_matches.get(0) {
819+
if let Some((row, view)) = combined_matches.first() {
820820
view.list.select_row(Some(row));
821821
}
822822
}
@@ -866,6 +866,10 @@ fn create_info_box(info: &PluginInfo, hide_icons: bool) -> gtk::Box {
866866
main_box
867867
}
868868

869+
// The linter warns about function pointer comparisons being unpredictable.
870+
// However in Anyrun's case since the function pointers reside in loaded libraries
871+
// they will always be predictable for comparison during runtime
872+
#[allow(unpredictable_function_pointer_comparisons)]
869873
/// Refresh the matches from the plugins
870874
fn refresh_matches(input: String, runtime_data: Rc<RefCell<RuntimeData>>) {
871875
for plugin_view in runtime_data.borrow().plugins.iter() {

plugins/applications/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ pub fn get_matches(input: RString, state: &State) -> RVec<Match> {
199199

200200
// prioritize actions
201201
if entry.desc.is_some() {
202-
score = score * 2;
202+
score *= 2;
203203
}
204204

205205
if score > 0 {
@@ -210,8 +210,7 @@ pub fn get_matches(input: RString, state: &State) -> RVec<Match> {
210210
})
211211
.collect::<Vec<_>>();
212212

213-
entries.sort_by(|a, b| b.2.cmp(&a.2)
214-
.then(a.0.name.cmp(&b.0.name)));
213+
entries.sort_by(|a, b| b.2.cmp(&a.2).then(a.0.name.cmp(&b.0.name)));
215214

216215
entries.truncate(state.config.max_entries);
217216
entries

plugins/randr/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub fn get_matches(input: RString, state: &State) -> RVec<Match> {
146146
]
147147
.iter()
148148
.map(|configure| Match {
149-
title: format!("{} {}", configure.to_string(), _mon.name).into(),
149+
title: format!("{} {}", configure, _mon.name).into(),
150150
description: ROption::RNone,
151151
use_pango: false,
152152
icon: ROption::RSome(configure.icon().into()),

plugins/randr/src/randr/mod.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::fmt::Display;
2+
13
pub mod dummy;
24
pub mod hyprland;
35

@@ -47,20 +49,20 @@ impl<'a> Configure<'a> {
4749
}
4850
}
4951

50-
impl<'a> ToString for Configure<'a> {
51-
fn to_string(&self) -> String {
52+
impl Display for Configure<'_> {
53+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5254
match self {
53-
Configure::Mirror(_) => "Mirror".to_string(),
54-
Configure::LeftOf(_) => "Left of".to_string(),
55-
Configure::RightOf(_) => "Right of".to_string(),
56-
Configure::Below(_) => "Below".to_string(),
57-
Configure::Above(_) => "Above".to_string(),
58-
Configure::Zero => "Zero".to_string(),
55+
Configure::Mirror(_) => f.write_str("Mirror"),
56+
Configure::LeftOf(_) => f.write_str("Left of"),
57+
Configure::RightOf(_) => f.write_str("Right of"),
58+
Configure::Below(_) => f.write_str("Below"),
59+
Configure::Above(_) => f.write_str("Above"),
60+
Configure::Zero => f.write_str("Zero"),
5961
}
6062
}
6163
}
6264

63-
impl<'a> From<&Configure<'a>> for u64 {
65+
impl From<&Configure<'_>> for u64 {
6466
fn from(configure: &Configure) -> u64 {
6567
match configure {
6668
Configure::Mirror(_) => 0,

plugins/stdin/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn init(config_dir: RString) -> State {
3535

3636
State {
3737
config,
38-
lines: stdin().lines().filter_map(|line| line.ok()).collect(),
38+
lines: stdin().lines().map_while(Result::ok).collect(),
3939
}
4040
}
4141

0 commit comments

Comments
 (0)