Apply Clippy recommendations
This commit is contained in:
parent
3afb007442
commit
2427d24980
7 changed files with 23 additions and 30 deletions
10
src/app.rs
10
src/app.rs
|
|
@ -98,7 +98,7 @@ impl App {
|
||||||
action_tx,
|
action_tx,
|
||||||
components: vec![
|
components: vec![
|
||||||
Box::new(Title::new()),
|
Box::new(Title::new()),
|
||||||
Box::new(FpsCounter::default()),
|
Box::new(FpsCounter::new()),
|
||||||
Box::new(Left::new()),
|
Box::new(Left::new()),
|
||||||
Box::new(Right::new()),
|
Box::new(Right::new()),
|
||||||
Box::new(Footer::new()),
|
Box::new(Footer::new()),
|
||||||
|
|
@ -298,12 +298,12 @@ impl App {
|
||||||
Action::Select(one, two) => {
|
Action::Select(one, two) => {
|
||||||
match self.cur_mode {
|
match self.cur_mode {
|
||||||
Mode::SelectDisks => {
|
Mode::SelectDisks => {
|
||||||
self.disk_index_source = one.clone();
|
self.disk_index_source = one;
|
||||||
self.disk_index_dest = two.clone();
|
self.disk_index_dest = two;
|
||||||
}
|
}
|
||||||
Mode::SelectParts => {
|
Mode::SelectParts => {
|
||||||
self.part_index_boot = one.clone();
|
self.part_index_boot = one;
|
||||||
self.part_index_os = two.clone();
|
self.part_index_os = two;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,14 +105,13 @@ impl Component for Left {
|
||||||
| Mode::SelectTableType
|
| Mode::SelectTableType
|
||||||
| Mode::SelectParts => {
|
| Mode::SelectParts => {
|
||||||
// Menu selection sections
|
// Menu selection sections
|
||||||
let selection: Option<usize>;
|
let selection: Option<usize> = match self.mode {
|
||||||
match self.mode {
|
Mode::InstallDrivers => self.list_drivers.selected(),
|
||||||
Mode::InstallDrivers => selection = self.list_drivers.selected(),
|
Mode::SelectDisks => self.list_disks.selected(),
|
||||||
Mode::SelectDisks => selection = self.list_disks.selected(),
|
Mode::SelectTableType => self.list_table_types.selected(),
|
||||||
Mode::SelectTableType => selection = self.list_table_types.selected(),
|
Mode::SelectParts => self.list_parts.selected(),
|
||||||
Mode::SelectParts => selection = self.list_parts.selected(),
|
|
||||||
_ => panic!("This shouldn't happen!"),
|
_ => panic!("This shouldn't happen!"),
|
||||||
}
|
};
|
||||||
if let Some(index) = selection {
|
if let Some(index) = selection {
|
||||||
if let Some(command_tx) = self.command_tx.clone() {
|
if let Some(command_tx) = self.command_tx.clone() {
|
||||||
let mut selection_one: Option<usize> = None;
|
let mut selection_one: Option<usize> = None;
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ impl Component for Popup {
|
||||||
Action::DismissPopup => self.popup_text.clear(),
|
Action::DismissPopup => self.popup_text.clear(),
|
||||||
Action::DisplayPopup(new_type, new_text) => {
|
Action::DisplayPopup(new_type, new_text) => {
|
||||||
self.popup_type = new_type;
|
self.popup_type = new_type;
|
||||||
self.popup_text = String::from(new_text);
|
self.popup_text = new_text;
|
||||||
}
|
}
|
||||||
Action::SetMode(mode) => {
|
Action::SetMode(mode) => {
|
||||||
if mode == Mode::ScanDisks {
|
if mode == Mode::ScanDisks {
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,7 @@ impl<T: Clone> StatefulList<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_selected(&self) -> Option<T> {
|
pub fn get_selected(&self) -> Option<T> {
|
||||||
if let Some(i) = self.state.selected() {
|
self.state.selected().map(|i| self.items[i].clone())
|
||||||
Some(self.items[i].clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,6 @@ pub fn get_fake_disks() -> Vec<Disk> {
|
||||||
letter: String::from("Q"),
|
letter: String::from("Q"),
|
||||||
part_type: String::from("EFI"),
|
part_type: String::from("EFI"),
|
||||||
size: 272_629_760,
|
size: 272_629_760,
|
||||||
..Default::default()
|
|
||||||
},
|
},
|
||||||
Partition {
|
Partition {
|
||||||
id: 2,
|
id: 2,
|
||||||
|
|
@ -236,7 +235,6 @@ pub fn get_fake_disks() -> Vec<Disk> {
|
||||||
letter: String::from("V"),
|
letter: String::from("V"),
|
||||||
part_type: String::from("MS Basic Data"),
|
part_type: String::from("MS Basic Data"),
|
||||||
size: 824_340_119_552,
|
size: 824_340_119_552,
|
||||||
..Default::default()
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
serial: "80085".to_string(),
|
serial: "80085".to_string(),
|
||||||
|
|
@ -337,7 +335,6 @@ fn refresh_fake_disk_info() -> Vec<Partition> {
|
||||||
letter: String::from("S"),
|
letter: String::from("S"),
|
||||||
part_type: String::from("EFI"),
|
part_type: String::from("EFI"),
|
||||||
size: 272_629_760,
|
size: 272_629_760,
|
||||||
..Default::default()
|
|
||||||
},
|
},
|
||||||
Partition {
|
Partition {
|
||||||
id: 2,
|
id: 2,
|
||||||
|
|
@ -353,7 +350,6 @@ fn refresh_fake_disk_info() -> Vec<Partition> {
|
||||||
letter: String::from("W"),
|
letter: String::from("W"),
|
||||||
part_type: String::from("MS Basic Data"),
|
part_type: String::from("MS Basic Data"),
|
||||||
size: 824_340_119_552,
|
size: 824_340_119_552,
|
||||||
..Default::default()
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,7 @@ pub fn parse_disk_numbers(contents: &str) -> Vec<&str> {
|
||||||
disk_nums
|
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(|| {
|
static RE_PAR: Lazy<Regex> = Lazy::new(|| {
|
||||||
Regex::new(
|
Regex::new(
|
||||||
r"Partition (\d+)\r?\nType\s*: (\S+)(\r?\n.*){5}\s*(Volume.*\r?\n.*\r?\n|There is no volume)(.*)",
|
r"Partition (\d+)\r?\nType\s*: (\S+)(\r?\n.*){5}\s*(Volume.*\r?\n.*\r?\n|There is no volume)(.*)",
|
||||||
|
|
|
||||||
16
src/tasks.rs
16
src/tasks.rs
|
|
@ -144,7 +144,7 @@ impl Tasks {
|
||||||
}
|
}
|
||||||
} {
|
} {
|
||||||
let msg = format!("{:?}", &action);
|
let msg = format!("{:?}", &action);
|
||||||
if let Err(_) = task_tx.send(action) {
|
if task_tx.send(action).is_err() {
|
||||||
panic!("Failed to send Action: {msg}");
|
panic!("Failed to send Action: {msg}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -159,12 +159,14 @@ impl Tasks {
|
||||||
let script = String::from(script);
|
let script = String::from(script);
|
||||||
self.handle = Some(thread::spawn(move || {
|
self.handle = Some(thread::spawn(move || {
|
||||||
let output = diskpart::run_script_raw(script.as_str());
|
let output = diskpart::run_script_raw(script.as_str());
|
||||||
if !output.status.success() {
|
if !output.status.success()
|
||||||
if let Err(_) = task_tx.send(Action::Error(String::from(
|
&& task_tx
|
||||||
"Diskpart script returned an error",
|
.send(Action::Error(String::from(
|
||||||
))) {
|
"Diskpart script returned an error",
|
||||||
panic!("Failed to send Action: {task_str:?}");
|
)))
|
||||||
}
|
.is_err()
|
||||||
|
{
|
||||||
|
panic!("Failed to send Action: {task_str:?}");
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue