summaryrefslogtreecommitdiff
path: root/alacritty_terminal
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2022-10-12 04:40:46 +0000
committerGitHub <noreply@github.com>2022-10-12 07:40:46 +0300
commit21c75d9d94e1a338501d2011f17710ff5174ac01 (patch)
tree310d88754f399dc0fe4f8abdc68ba2d4097bdefd /alacritty_terminal
parent182086f59c0148508c31d359eaee2cfef059f45c (diff)
downloadalacritty-21c75d9d94e1a338501d2011f17710ff5174ac01.tar.gz
alacritty-21c75d9d94e1a338501d2011f17710ff5174ac01.zip
Fix clippy warnings
This patch applies all clippy lints currently present on the latest clippy master than are compatible with our oldstable clippy (only exception is the `_else(||` stuff).
Diffstat (limited to 'alacritty_terminal')
-rw-r--r--alacritty_terminal/src/config/mod.rs8
-rw-r--r--alacritty_terminal/src/term/color.rs6
-rw-r--r--alacritty_terminal/src/term/mod.rs8
3 files changed, 8 insertions, 14 deletions
diff --git a/alacritty_terminal/src/config/mod.rs b/alacritty_terminal/src/config/mod.rs
index f63f6ebb..f17c327f 100644
--- a/alacritty_terminal/src/config/mod.rs
+++ b/alacritty_terminal/src/config/mod.rs
@@ -234,13 +234,7 @@ impl Default for Percentage {
impl Percentage {
pub fn new(value: f32) -> Self {
- Percentage(if value < 0.0 {
- 0.0
- } else if value > 1.0 {
- 1.0
- } else {
- value
- })
+ Percentage(value.clamp(0., 1.))
}
pub fn as_f32(self) -> f32 {
diff --git a/alacritty_terminal/src/term/color.rs b/alacritty_terminal/src/term/color.rs
index 3c545b28..22b30828 100644
--- a/alacritty_terminal/src/term/color.rs
+++ b/alacritty_terminal/src/term/color.rs
@@ -64,9 +64,9 @@ impl Mul<f32> for Rgb {
fn mul(self, rhs: f32) -> Rgb {
let result = Rgb {
- r: (f32::from(self.r) * rhs).max(0.0).min(255.0) as u8,
- g: (f32::from(self.g) * rhs).max(0.0).min(255.0) as u8,
- b: (f32::from(self.b) * rhs).max(0.0).min(255.0) as u8,
+ r: (f32::from(self.r) * rhs).clamp(0.0, 255.0) as u8,
+ g: (f32::from(self.g) * rhs).clamp(0.0, 255.0) as u8,
+ b: (f32::from(self.b) * rhs).clamp(0.0, 255.0) as u8,
};
trace!("Scaling RGB by {} from {:?} to {:?}", rhs, self, result);
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 8317e701..98f76d52 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -202,7 +202,7 @@ impl TermDamageState {
/// Damage point inside of the viewport.
#[inline]
fn damage_point(&mut self, point: Point<usize>) {
- self.damage_line(point.line, point.column.0 as usize, point.column.0 as usize);
+ self.damage_line(point.line, point.column.0, point.column.0);
}
/// Expand `line`'s damage to span at least `left` to `right` column.
@@ -228,7 +228,7 @@ impl TermDamageState {
};
let start = cmp::max(selection.start.line.0 + display_offset, 0);
- let end = cmp::min(cmp::max(selection.end.line.0 + display_offset, 0), last_visible_line);
+ let end = (selection.end.line.0 + display_offset).clamp(0, last_visible_line);
for line in start as usize..=end as usize {
self.damage_line(line, 0, num_cols - 1);
}
@@ -1244,7 +1244,7 @@ impl<T: EventListener> Handler for Term<T> {
if self.grid.cursor.point.column > Column(0) {
let line = self.grid.cursor.point.line.0 as usize;
- let column = self.grid.cursor.point.column.0 as usize;
+ let column = self.grid.cursor.point.column.0;
self.grid.cursor.point.column -= 1;
self.grid.cursor.input_needs_wrap = false;
self.damage.damage_line(line, column - 1, column);
@@ -1547,7 +1547,7 @@ impl<T: EventListener> Handler for Term<T> {
self.event_proxy.send_event(Event::ClipboardLoad(
clipboard_type,
Arc::new(move |text| {
- let base64 = base64::encode(&text);
+ let base64 = base64::encode(text);
format!("\x1b]52;{};{}{}", clipboard as char, base64, terminator)
}),
));