Skip to content

Commit 4ba3ae1

Browse files
committed
Fix some warnings
1 parent 7d297a8 commit 4ba3ae1

File tree

8 files changed

+25
-42
lines changed

8 files changed

+25
-42
lines changed

src/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,8 @@ winapi = { version = "0.3", features = ["consoleapi", "winuser"] }
9393
[lints.clippy]
9494
collapsible_else_if = "allow"
9595
collapsible_if = "allow"
96+
module_inception = "allow"
97+
redundant_closure = "allow"
98+
single_match = "allow"
99+
upper_case_acronyms = "allow"
96100
while_let_loop = "allow"

src/kernel/proc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::{HashMap, HashSet};
1+
use std::collections::HashMap;
22

33
use serde::{Deserialize, Serialize};
44
use tokio::sync::mpsc::UnboundedSender;

src/modal/add_proc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Modal for AddProcModal {
6464
_ => (),
6565
}
6666

67-
let req = tui_input::backend::crossterm::to_input_request(&event);
67+
let req = tui_input::backend::crossterm::to_input_request(event);
6868
if let Some(req) = req {
6969
self.input.handle(req);
7070
loop_action.render();
@@ -107,6 +107,6 @@ impl Modal for AddProcModal {
107107
&mut cursor,
108108
);
109109

110-
frame.set_cursor(cursor.0, cursor.1);
110+
frame.set_cursor_position((cursor.0, cursor.1));
111111
}
112112
}

src/modal/rename_proc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ impl Modal for RenameProcModal {
106106
&mut cursor,
107107
);
108108

109-
frame.set_cursor(cursor.0, cursor.1);
109+
frame.set_cursor_position((cursor.0, cursor.1));
110110
}
111111
}

src/proc/mod.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use tui::layout::Rect;
1313

1414
use crate::kernel::proc::ProcId;
1515
use crate::key::Key;
16-
use crate::mouse::MouseEvent;
1716
use crate::vt100::TermReplySender;
1817
use crate::yaml_val::Val;
1918

@@ -53,13 +52,6 @@ impl StopSignal {
5352
}
5453
}
5554

56-
fn translate_mouse_pos(event: &MouseEvent, scrollback: usize) -> Pos {
57-
Pos {
58-
y: event.y - scrollback as i32,
59-
x: event.x,
60-
}
61-
}
62-
6355
#[derive(Clone)]
6456
pub struct Size {
6557
width: u16,
@@ -97,12 +89,11 @@ pub struct Pos {
9789

9890
impl Pos {
9991
pub fn to_low_high<'a>(a: &'a Self, b: &'a Self) -> (&'a Self, &'a Self) {
100-
if a.y > b.y {
101-
return (b, a);
102-
} else if a.y == b.y && a.x > b.x {
103-
return (b, a);
92+
if a.y < b.y || a.y == b.y && a.x < b.x {
93+
(a, b)
94+
} else {
95+
(b, a)
10496
}
105-
(a, b)
10697
}
10798

10899
pub fn within(start: &Self, end: &Self, target: &Self) -> bool {
@@ -111,13 +102,7 @@ impl Pos {
111102
let (low, high) = Pos::to_low_high(start, end);
112103

113104
if y > low.y {
114-
if y < high.y {
115-
true
116-
} else if y == high.y && x <= high.x {
117-
true
118-
} else {
119-
false
120-
}
105+
y < high.y || y == high.y && x <= high.x
121106
} else if y == low.y {
122107
if y < high.y {
123108
x >= low.x

src/proc/msg.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use std::{any::Any, fmt::Debug};
33
use compact_str::CompactString;
44

55
use crate::{
6-
kernel::{
7-
kernel_message::SharedVt,
8-
proc::{ProcId, ProcStatus},
9-
},
6+
kernel::{kernel_message::SharedVt, proc::ProcId},
107
key::Key,
118
mouse::MouseEvent,
129
};

src/proc/view.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl ProcView {
6262
self.exit_code
6363
}
6464

65-
pub fn lock_view(&self) -> ProcViewFrame {
65+
pub fn lock_view(&'_ self) -> ProcViewFrame<'_> {
6666
match &self.vt {
6767
None => ProcViewFrame::Empty,
6868
Some(vt) => vt

src/yaml_val.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ use indexmap::IndexMap;
55
use serde_yaml::Value;
66

77
#[derive(Clone)]
8-
struct Trace(Option<Rc<Box<(String, Trace)>>>);
8+
struct Trace(Option<Rc<(String, Trace)>>);
99

1010
impl Trace {
1111
pub fn empty() -> Self {
1212
Trace(None)
1313
}
1414

1515
pub fn add<T: ToString>(&self, seg: T) -> Self {
16-
Trace(Some(Rc::new(Box::new((seg.to_string(), self.clone())))))
16+
Trace(Some(Rc::new((seg.to_string(), self.clone()))))
1717
}
1818

19+
#[allow(clippy::inherent_to_string)]
1920
pub fn to_string(&self) -> String {
2021
let mut str = String::new();
2122
fn add(buf: &mut String, trace: &Trace) {
@@ -44,11 +45,7 @@ impl<'a> Val<'a> {
4445
fn create(value: &'a Value, trace: Trace) -> anyhow::Result<Self> {
4546
match value {
4647
Value::Mapping(map) => {
47-
if map
48-
.into_iter()
49-
.next()
50-
.map_or(false, |(k, _)| k.eq("$select"))
51-
{
48+
if map.into_iter().next().is_some_and(|(k, _)| k.eq("$select")) {
5249
let (v, t) = Self::select(map, trace.clone())?;
5350
return Self::create(v, t);
5451
}
@@ -66,12 +63,12 @@ impl<'a> Val<'a> {
6663
map: &'a serde_yaml::Mapping,
6764
trace: Trace,
6865
) -> anyhow::Result<(&'a Value, Trace)> {
69-
if map.get(&Value::from("$select")).unwrap() == "os" {
70-
if let Some(v) = map.get(&Value::from(OS)) {
66+
if map.get(Value::from("$select")).unwrap() == "os" {
67+
if let Some(v) = map.get(Value::from(OS)) {
7168
return Ok((v, trace.add(OS)));
7269
}
7370

74-
if let Some(v) = map.get(&Value::from("$else")) {
71+
if let Some(v) = map.get(Value::from("$else")) {
7572
return Ok((v, trace.add("$else")));
7673
}
7774

@@ -110,7 +107,7 @@ impl<'a> Val<'a> {
110107
})
111108
}
112109

113-
pub fn as_array(&self) -> anyhow::Result<Vec<Val>> {
110+
pub fn as_array(&'_ self) -> anyhow::Result<Vec<Val<'_>>> {
114111
self
115112
.0
116113
.as_sequence()
@@ -123,7 +120,7 @@ impl<'a> Val<'a> {
123120
.collect::<anyhow::Result<Vec<_>>>()
124121
}
125122

126-
pub fn as_object(&self) -> anyhow::Result<IndexMap<Value, Val>> {
123+
pub fn as_object(&'_ self) -> anyhow::Result<IndexMap<Value, Val<'_>>> {
127124
self
128125
.0
129126
.as_mapping()
@@ -138,7 +135,7 @@ impl<'a> Val<'a> {
138135
item: &'a Value,
139136
trace: &'a Trace,
140137
) -> anyhow::Result<Val<'a>> {
141-
Ok(Val::create(item, trace.add(value_to_string(k)?))?)
138+
Val::create(item, trace.add(value_to_string(k)?))
142139
}
143140
Ok((k.to_owned(), mk_val(k, item, &self.1)?))
144141
})

0 commit comments

Comments
 (0)