Skip to content

Commit 1e07266

Browse files
authored
Merge pull request #6 from derenv/indentation1
Indentation1
2 parents b39e405 + 6bc2698 commit 1e07266

File tree

2 files changed

+34
-51
lines changed

2 files changed

+34
-51
lines changed

src/main.rs

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ mod custom_button;
2424
mod subprocess;
2525
mod processor;
2626

27-
use std::ffi::OsStr;
28-
2927
// Imports
28+
use std::ffi::OsStr;
3029
use gtk::prelude::*;
3130
use gtk::{
3231
/* Libraries */ gio,
@@ -93,37 +92,25 @@ fn build_ui(app: &Application) {
9392
],
9493
None::<&gio::Cancellable>,
9594
) {
96-
Ok(return_val) => {
97-
match return_val {
98-
(None, None) => println!("no stdout or stderr, something went really wrong..."),
99-
(None, Some(stderr_buffer)) => {
100-
match std::str::from_utf8(&stderr_buffer) {
101-
Ok(stderr_buffer_contents) => println!("Process failed with error: {}", stderr_buffer_contents),
102-
Err(err) => panic!("{}", err),
103-
}
95+
Ok(return_val) => match return_val {
96+
(None, None) => println!("no stdout or stderr, something went really wrong..."),
97+
(None, Some(stderr_buffer)) => match std::str::from_utf8(&stderr_buffer) {
98+
Ok(stderr_buffer_contents) => println!("Process failed with error: {}", stderr_buffer_contents),
99+
Err(err) => panic!("{}", err),
100+
},
101+
(Some(stdout_buffer), None) => match std::str::from_utf8(&stdout_buffer) {
102+
Ok(stdout_buffer_contents) => println!("Process suceeded, returning: {}", stdout_buffer_contents),
103+
Err(err) => panic!("{}", err),
104+
},
105+
(Some(stdout_buffer), Some(stderr_buffer)) => match std::str::from_utf8(&stdout_buffer) {
106+
Ok(stdout_buffer_contents) => match std::str::from_utf8(&stderr_buffer) {
107+
Ok(stderr_buffer_contents) => println!("Process suceeded, returning: {} but with error: {}", stdout_buffer_contents, stderr_buffer_contents),
108+
Err(err) => panic!("{}", err),
104109
},
105-
(Some(stdout_buffer), None) => {
106-
match std::str::from_utf8(&stdout_buffer) {
107-
Ok(stdout_buffer_contents) => println!("Process suceeded, returning: {}", stdout_buffer_contents),
108-
Err(err) => panic!("{}", err),
109-
}
110-
},
111-
(Some(stdout_buffer), Some(stderr_buffer)) => {
112-
match std::str::from_utf8(&stdout_buffer) {
113-
Ok(stdout_buffer_contents)=> {
114-
match std::str::from_utf8(&stderr_buffer) {
115-
Ok(stderr_buffer_contents) => println!("Process suceeded, returning: {} but with error: {}", stdout_buffer_contents, stderr_buffer_contents),
116-
Err(err) => panic!("{}", err),
117-
}
118-
},
119-
Err(err) => panic!("{}", err),
120-
}
121-
},
122-
}
123-
}
124-
Err(_y) => {
125-
println!("something went wrong!"); //DEBUG
110+
Err(err) => panic!("{}", err),
111+
},
126112
}
113+
Err(_y) => println!("something went wrong!"), //DEBUG
127114
};
128115
});
129116

src/subprocess/mod.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,10 @@ pub fn exec_check(
5151
// Create subprocess
5252
match gio::Subprocess::newv(argv, gio::SubprocessFlags::NONE) {
5353
Err(err) => Err(err),
54-
Ok(proc) => {
55-
// Run subprocess
56-
match proc.wait_async(cancellable, |_| ()) {
57-
_ => Ok(()),
58-
}
59-
}
54+
// Run subprocess
55+
Ok(proc) => match proc.wait_async(cancellable, |_| ()) {
56+
_ => Ok(()),
57+
},
6058
}
6159
}
6260

@@ -87,19 +85,17 @@ pub fn exec_communicate(
8785
// Create subprocess
8886
match gio::Subprocess::newv(argv, gio::SubprocessFlags::STDOUT_PIPE) {
8987
Err(err) => Err(err),
90-
Ok(proc) => {
91-
// Run subprocess
92-
match proc.communicate(None, cancellable) {
93-
Err(err) => Err(err),
94-
Ok(buffers) => match buffers {
95-
(None, None) => Ok((None, None)),
96-
(None, Some(stderr_buffer)) => Ok((None, Some(stderr_buffer))),
97-
(Some(stdout_buffer), None) => Ok((Some(stdout_buffer), None)),
98-
(Some(stdout_buffer), Some(stderr_buffer)) => {
99-
Ok((Some(stdout_buffer), Some(stderr_buffer)))
100-
}
101-
},
102-
}
103-
}
88+
// Run subprocess
89+
Ok(proc) => match proc.communicate(None, cancellable) {
90+
Err(err) => Err(err),
91+
Ok(buffers) => match buffers {
92+
(None, None) => Ok((None, None)),
93+
(None, Some(stderr_buffer)) => Ok((None, Some(stderr_buffer))),
94+
(Some(stdout_buffer), None) => Ok((Some(stdout_buffer), None)),
95+
(Some(stdout_buffer), Some(stderr_buffer)) => {
96+
Ok((Some(stdout_buffer), Some(stderr_buffer)))
97+
}
98+
},
99+
},
104100
}
105101
}

0 commit comments

Comments
 (0)