Skip to content

Commit 03527dc

Browse files
authored
Merge pull request #37 from lonesometraveler/refactor_gui_4
Simplify PathBuf setting
2 parents f2450c0 + d7fc730 commit 03527dc

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

src/gui.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -474,31 +474,15 @@ impl eframe::App for MyApp {
474474
};
475475
ui.end_row();
476476
if ui.button("Save to file").clicked() {
477-
match rfd::FileDialog::new().save_file() {
478-
Some(mut path) => {
479-
let extension = "csv";
480-
match path.extension() {
481-
None => {
482-
path.set_extension(extension);
483-
}
484-
Some(ext) => {
485-
if ext != "csv" {
486-
path.set_extension(extension);
487-
}
488-
}
489-
}
490-
self.picked_path = path;
491-
}
492-
None => self.picked_path = PathBuf::new(),
493-
}
494-
match self.save_tx.send(self.picked_path.clone()) {
495-
Ok(_) => {}
496-
Err(err) => {
477+
if let Some(path) = rfd::FileDialog::new().save_file() {
478+
self.picked_path = path;
479+
self.picked_path.set_extension("csv");
480+
if let Err(e) = self.save_tx.send(self.picked_path.clone()) {
497481
print_to_console(
498482
&self.print_lock,
499483
Print::Error(format!(
500484
"save_tx thread send failed: {:?}",
501-
err
485+
e
502486
)),
503487
);
504488
}

0 commit comments

Comments
 (0)