Skip to content

Commit bd79adb

Browse files
committed
chore: Fix some clippy lints
1 parent 289c02c commit bd79adb

File tree

8 files changed

+17
-21
lines changed

8 files changed

+17
-21
lines changed

src/application/keyboard.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,15 @@ impl Keyboard {
392392
}
393393
KeyMap {
394394
board: self.board_name().to_string(),
395-
map: map,
395+
map,
396396
}
397397
}
398398

399399
pub fn import_keymap(&self, keymap: &KeyMap) {
400400
// TODO: don't block UI thread
401401
// TODO: Ideally don't want this function to be O(Keys^2)
402402

403-
if &keymap.board != self.board_name() {
403+
if keymap.board != self.board_name() {
404404
error_dialog(
405405
&self.window().unwrap(),
406406
"Failed to import keymap",

src/application/layout/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl Layout {
149149
logical_name,
150150
physical: Rect::new(x, y, w, h),
151151
physical_name: name.clone(),
152-
electrical: electrical.clone(),
152+
electrical: *electrical,
153153
electrical_name: format!("{}, {}", electrical.0, electrical.1),
154154
scancodes: RefCell::new(Vec::new()),
155155
background_color,

src/application/picker/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use picker_json::picker_json;
1717
use picker_key::PickerKey;
1818

1919
const DEFAULT_COLS: i32 = 3;
20-
const PICKER_CSS: &'static str = r#"
20+
const PICKER_CSS: &str = r#"
2121
button {
2222
margin: 0;
2323
padding: 0;

src/color_circle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl ObjectImpl for ColorCircleInner {
9393
match pspec.get_name() {
9494
"rgb" => {
9595
let rgb: &Rgb = value.get_some().unwrap();
96-
widget.set_rgb(rgb.clone());
96+
widget.set_rgb(*rgb);
9797
}
9898
_ => unimplemented!(),
9999
}

src/color_wheel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl ColorWheel {
141141
let Rgb { r, g, b } = Hs::new(angle, distance / radius).to_rgb();
142142

143143
let offset = (row * stride + col * 4) as usize;
144-
data[offset + 0] = b;
144+
data[offset] = b;
145145
data[offset + 1] = g;
146146
data[offset + 2] = r;
147147
}

src/daemon/dummy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct DaemonDummy {
2020

2121
impl DaemonDummy {
2222
fn board(&self, board: usize) -> Result<&BoardDummy, String> {
23-
self.boards.get(board).ok_or("No board".to_string())
23+
self.boards.get(board).ok_or_else(|| "No board".to_string())
2424
}
2525
}
2626

src/daemon/s76power.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use std::{cell::Cell, iter::Iterator};
88
use super::{err_str, Daemon};
99
use crate::color::Rgb;
1010

11-
const DBUS_NAME: &'static str = "com.system76.PowerDaemon";
12-
const DBUS_KEYBOARD_IFACE: &'static str = "com.system76.PowerDaemon.Keyboard";
11+
const DBUS_NAME: &str = "com.system76.PowerDaemon";
12+
const DBUS_KEYBOARD_IFACE: &str = "com.system76.PowerDaemon.Keyboard";
1313

1414
struct Keyboard {
1515
proxy: gio::DBusProxy,
@@ -79,7 +79,7 @@ pub struct DaemonS76Power {
7979

8080
impl DaemonS76Power {
8181
fn board(&self, board: usize) -> Result<&Keyboard, String> {
82-
self.boards.get(board).ok_or("No board".to_string())
82+
self.boards.get(board).ok_or_else(|| "No board".to_string())
8383
}
8484
}
8585

@@ -158,7 +158,7 @@ impl Daemon for DaemonS76Power {
158158
let color = self.board(board)?.prop::<String>("color")?;
159159
Ok(color
160160
.and_then(|c| Rgb::parse(&c))
161-
.unwrap_or(Rgb::new(0, 0, 0)))
161+
.unwrap_or_else(|| Rgb::new(0, 0, 0)))
162162
}
163163

164164
fn set_color(&self, board: usize, color: Rgb) -> Result<(), String> {

src/keyboard_color_button.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl ObjectImpl for KeyboardColorButtonInner {
122122
match pspec.get_name() {
123123
"rgb" => {
124124
let rgb: &Rgb = value.get_some().unwrap();
125-
widget.set_rgb(rgb.clone());
125+
widget.set_rgb(*rgb);
126126
widget.notify("rgb");
127127
}
128128
_ => unimplemented!(),
@@ -219,11 +219,9 @@ impl KeyboardColorButton {
219219
self.add_color(color);
220220
self.inner().remove_button.set_visible(true);
221221
self.populate_grid();
222-
} else {
223-
if let Some(circle) = &*self.inner().current_circle.borrow() {
224-
if let Err(err) = self.board().set_color(circle.rgb()) {
225-
eprintln!("Failed to set keyboard color: {}", err);
226-
}
222+
} else if let Some(circle) = &*self.inner().current_circle.borrow() {
223+
if let Err(err) = self.board().set_color(circle.rgb()) {
224+
eprintln!("Failed to set keyboard color: {}", err);
227225
}
228226
}
229227
}
@@ -247,10 +245,8 @@ impl KeyboardColorButton {
247245
choose_color(self.board().clone(), self, "Edit Color", Some(circle.rgb()))
248246
{
249247
circle.set_rgb(color);
250-
} else {
251-
if let Err(err) = self.board().set_color(circle.rgb()) {
252-
eprintln!("Failed to set keyboard color: {}", err);
253-
}
248+
} else if let Err(err) = self.board().set_color(circle.rgb()) {
249+
eprintln!("Failed to set keyboard color: {}", err);
254250
}
255251
}
256252
}

0 commit comments

Comments
 (0)