Apply Clippy recommendations

This commit is contained in:
2Shirt 2024-11-17 15:17:07 -08:00
parent 3afb007442
commit 2427d24980
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
7 changed files with 23 additions and 30 deletions

View file

@ -98,7 +98,7 @@ impl App {
action_tx,
components: vec![
Box::new(Title::new()),
Box::new(FpsCounter::default()),
Box::new(FpsCounter::new()),
Box::new(Left::new()),
Box::new(Right::new()),
Box::new(Footer::new()),
@ -298,12 +298,12 @@ impl App {
Action::Select(one, two) => {
match self.cur_mode {
Mode::SelectDisks => {
self.disk_index_source = one.clone();
self.disk_index_dest = two.clone();
self.disk_index_source = one;
self.disk_index_dest = two;
}
Mode::SelectParts => {
self.part_index_boot = one.clone();
self.part_index_os = two.clone();
self.part_index_boot = one;
self.part_index_os = two;
}
_ => {}
}

View file

@ -105,14 +105,13 @@ impl Component for Left {
| Mode::SelectTableType
| Mode::SelectParts => {
// Menu selection sections
let selection: Option<usize>;
match self.mode {
Mode::InstallDrivers => selection = self.list_drivers.selected(),
Mode::SelectDisks => selection = self.list_disks.selected(),
Mode::SelectTableType => selection = self.list_table_types.selected(),
Mode::SelectParts => selection = self.list_parts.selected(),
let selection: Option<usize> = match self.mode {
Mode::InstallDrivers => self.list_drivers.selected(),
Mode::SelectDisks => self.list_disks.selected(),
Mode::SelectTableType => self.list_table_types.selected(),
Mode::SelectParts => self.list_parts.selected(),
_ => panic!("This shouldn't happen!"),
}
};
if let Some(index) = selection {
if let Some(command_tx) = self.command_tx.clone() {
let mut selection_one: Option<usize> = None;

View file

@ -70,7 +70,7 @@ impl Component for Popup {
Action::DismissPopup => self.popup_text.clear(),
Action::DisplayPopup(new_type, new_text) => {
self.popup_type = new_type;
self.popup_text = String::from(new_text);
self.popup_text = new_text;
}
Action::SetMode(mode) => {
if mode == Mode::ScanDisks {

View file

@ -36,11 +36,7 @@ impl<T: Clone> StatefulList<T> {
}
pub fn get_selected(&self) -> Option<T> {
if let Some(i) = self.state.selected() {
Some(self.items[i].clone())
} else {
None
}
self.state.selected().map(|i| self.items[i].clone())
}
pub fn is_empty(&self) -> bool {

View file

@ -221,7 +221,6 @@ pub fn get_fake_disks() -> Vec<Disk> {
letter: String::from("Q"),
part_type: String::from("EFI"),
size: 272_629_760,
..Default::default()
},
Partition {
id: 2,
@ -236,7 +235,6 @@ pub fn get_fake_disks() -> Vec<Disk> {
letter: String::from("V"),
part_type: String::from("MS Basic Data"),
size: 824_340_119_552,
..Default::default()
},
],
serial: "80085".to_string(),
@ -337,7 +335,6 @@ fn refresh_fake_disk_info() -> Vec<Partition> {
letter: String::from("S"),
part_type: String::from("EFI"),
size: 272_629_760,
..Default::default()
},
Partition {
id: 2,
@ -353,7 +350,6 @@ fn refresh_fake_disk_info() -> Vec<Partition> {
letter: String::from("W"),
part_type: String::from("MS Basic Data"),
size: 824_340_119_552,
..Default::default()
},
]
}

View file

@ -290,7 +290,7 @@ pub fn parse_disk_numbers(contents: &str) -> Vec<&str> {
disk_nums
}
pub fn parse_partition_details(parts: &mut Vec<Partition>, contents: &str) {
pub fn parse_partition_details(parts: &mut [Partition], contents: &str) {
static RE_PAR: Lazy<Regex> = Lazy::new(|| {
Regex::new(
r"Partition (\d+)\r?\nType\s*: (\S+)(\r?\n.*){5}\s*(Volume.*\r?\n.*\r?\n|There is no volume)(.*)",

View file

@ -144,7 +144,7 @@ impl Tasks {
}
} {
let msg = format!("{:?}", &action);
if let Err(_) = task_tx.send(action) {
if task_tx.send(action).is_err() {
panic!("Failed to send Action: {msg}");
}
}
@ -159,13 +159,15 @@ impl Tasks {
let script = String::from(script);
self.handle = Some(thread::spawn(move || {
let output = diskpart::run_script_raw(script.as_str());
if !output.status.success() {
if let Err(_) = task_tx.send(Action::Error(String::from(
if !output.status.success()
&& task_tx
.send(Action::Error(String::from(
"Diskpart script returned an error",
))) {
)))
.is_err()
{
panic!("Failed to send Action: {task_str:?}");
}
}
}));
} else {
// Simulate task if not running under Windows