summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorMax Verevkin <maxxverrr@gmail.com>2022-04-03 22:52:12 +0300
committerMax Verevkin <maxxverrr@gmail.com>2022-04-03 22:52:26 +0300
commit41b54360ff917a261d3f6f752e3c2c51edada773 (patch)
tree2a7beaea62e7da5cdaef29ab5d26db126131c2ea /src/main.rs
parent6ab71396f028f6945d2e7554b65c64de146d7e87 (diff)
downloadi3bar-mango-41b54360ff917a261d3f6f752e3c2c51edada773.tar.gz
small refactoring
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs
index 85d61d8..1fe335e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,3 @@
-#![allow(clippy::derive_ord_xor_partial_ord)]
-
#[macro_use]
extern crate log;
@@ -31,6 +29,7 @@ mod color;
mod config;
mod i3bar_protocol;
mod lines_buffer;
+mod ord_adaptor;
mod pointer_btn;
mod river_protocols;
mod status_cmd;
@@ -40,6 +39,7 @@ mod text;
use button_manager::ButtonManager;
use config::Config;
use i3bar_protocol::{Block, MinWidth};
+use ord_adaptor::DefaultLess;
use pointer_btn::PointerBtn;
use river_protocols::zriver_command_callback_v1;
use river_protocols::zriver_control_v1;
@@ -632,10 +632,10 @@ fn render_blocks(
let mut heap = BinaryHeap::new();
for (name, delta) in deltas {
if delta > 0.0 {
- heap.push((OrdFloat(delta), name));
+ heap.push((DefaultLess(delta), name));
}
}
- while let Some((OrdFloat(delta), to_switch)) = heap.pop() {
+ while let Some((DefaultLess(delta), to_switch)) = heap.pop() {
for (name, full, short) in &mut blocks_computed {
if *name == Some(to_switch) {
if let Some(short) = short {
@@ -684,16 +684,3 @@ fn render_blocks(
}
}
}
-
-#[derive(PartialEq, PartialOrd)]
-struct OrdFloat(f64);
-
-impl Eq for OrdFloat {}
-
-impl Ord for OrdFloat {
- fn cmp(&self, other: &Self) -> std::cmp::Ordering {
- self.0
- .partial_cmp(&other.0)
- .unwrap_or(std::cmp::Ordering::Less)
- }
-}