Skip to content

Commit e8e6514

Browse files
author
Deren Vural
committed
trunk formatting fixes
Signed-off-by: Deren Vural <[email protected]>
1 parent 658d1d1 commit e8e6514

File tree

2 files changed

+77
-62
lines changed

2 files changed

+77
-62
lines changed

src/processor/imp.rs

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
*/
2222

2323
// Imports
24-
use gtk::glib::{ self, ParamSpec, Value };
24+
use gtk::glib::once_cell::sync::Lazy;
25+
use gtk::glib::{self, ParamSpec, Value};
2526
use gtk::prelude::*;
2627
use gtk::subclass::prelude::*;
27-
use gtk::glib::once_cell::sync::Lazy;
2828
use std::cell::Cell;
2929

3030
// Object holding the State
@@ -35,7 +35,6 @@ pub struct Processor {
3535
tail_call: Cell<String>,
3636
}
3737

38-
3938
// The central trait for subclassing a GObject
4039
#[glib::object_subclass]
4140
impl ObjectSubclass for Processor {
@@ -89,15 +88,13 @@ impl ObjectImpl for Processor {
8988
* glib::ParamSpecObject::builder("formatter").build(),
9089
*/
9190
fn properties() -> &'static [ParamSpec] {
92-
static PROPERTIES: Lazy<Vec<ParamSpec>> =
93-
Lazy::new(|| {
94-
vec![
95-
glib::ParamSpecString::builder("base-call").build(),
96-
glib::ParamSpecString::builder("call").build(),
97-
glib::ParamSpecString::builder("tail-call").build(),
98-
]
99-
}
100-
);
91+
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
92+
vec![
93+
glib::ParamSpecString::builder("base-call").build(),
94+
glib::ParamSpecString::builder("call").build(),
95+
glib::ParamSpecString::builder("tail-call").build(),
96+
]
97+
});
10198

10299
//println!("PROPERTIES: {:?}", PROPERTIES);//TEST
103100
//println!("trying to add `base_call`: {:?}", glib::ParamSpecString::builder("base_call").build());//TEST
@@ -121,32 +118,29 @@ impl ObjectImpl for Processor {
121118
* Notes:
122119
*
123120
*/
124-
fn set_property(
125-
&self,
126-
_obj: &Self::Type,
127-
_id: usize,
128-
value: &Value,
129-
pspec: &ParamSpec,
130-
) {
121+
fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
131122
//println!("setting: {:?}", pspec.name());//TEST
132123

133124
match pspec.name() {
134125
"base-call" => {
135-
let input_base_call =
136-
value.get().expect("The value needs to be of type `String`.");
126+
let input_base_call = value
127+
.get()
128+
.expect("The value needs to be of type `String`.");
137129
self.base_call.replace(input_base_call);
138-
},
130+
}
139131
"call" => {
140-
let input_call =
141-
value.get().expect("The value needs to be of type `String`.");
132+
let input_call = value
133+
.get()
134+
.expect("The value needs to be of type `String`.");
142135
self.call.replace(input_call);
143-
},
136+
}
144137
"tail-call" => {
145-
let input_tail_call =
146-
value.get().expect("The value needs to be of type `String`.");
147-
self.tail_call.replace( input_tail_call);
148-
},
149-
_ => unimplemented!(),//TODO
138+
let input_tail_call = value
139+
.get()
140+
.expect("The value needs to be of type `String`.");
141+
self.tail_call.replace(input_tail_call);
142+
}
143+
_ => unimplemented!(), //TODO
150144
}
151145
}
152146

@@ -176,25 +170,25 @@ impl ObjectImpl for Processor {
176170

177171
self.base_call.set(value.clone());
178172

179-
return value.to_value();
180-
},
173+
value.to_value()
174+
}
181175
"call" => {
182176
//TODO: this seems ridiculous..
183177
let value = self.call.take();
184178

185179
self.call.set(value.clone());
186180

187-
return value.to_value();
188-
},
181+
value.to_value()
182+
}
189183
"tail-call" => {
190184
//TODO: this seems ridiculous..
191185
let value = self.tail_call.take();
192186

193187
self.tail_call.set(value.clone());
194188

195-
return value.to_value();
196-
},
197-
_ => unimplemented!(),//TODO
189+
value.to_value()
190+
}
191+
_ => unimplemented!(), //TODO
198192
}
199193
}
200194
}

src/processor/mod.rs

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mod imp;
2525
// Imports
2626
use super::subprocess;
2727
use glib::Object;
28-
use gtk::{ glib, gio, prelude::ObjectExt };
28+
use gtk::{gio, glib, prelude::ObjectExt};
2929
use std::ffi::OsStr;
3030

3131
glib::wrapper! {
@@ -75,7 +75,7 @@ impl Processor {
7575
obj.set_property("call", base_call.to_string().clone());
7676
obj.set_property("tail-call", tail_call.to_string());
7777

78-
return obj;
78+
obj
7979
}
8080

8181
/*
@@ -98,7 +98,7 @@ impl Processor {
9898
// Create call stack of program and args
9999
let tail_call = self.property::<String>("tail-call");
100100
let mut call_stack = self.property::<String>("call");
101-
call_stack.push_str(" ");
101+
call_stack.push(' ');
102102
call_stack.push_str(tail_call.as_str());
103103

104104
// Turn call stack into bytes and create vector for final call stack
@@ -115,7 +115,7 @@ impl Processor {
115115
Ok(result) => {
116116
//println!("item: {}", result);//TEST
117117
item_osstr = OsStr::new(result)
118-
},
118+
}
119119
Err(err) => panic!("{}", err),
120120
}
121121
call_stack_items.insert(call_stack_items.len(), item_osstr);
@@ -128,7 +128,7 @@ impl Processor {
128128
Ok(result) => {
129129
//println!("item: {}", result);//TEST
130130
item_osstr = OsStr::new(result)
131-
},
131+
}
132132
Err(err) => panic!("{}", err),
133133
}
134134
call_stack_items.insert(call_stack_items.len(), item_osstr);
@@ -139,7 +139,12 @@ impl Processor {
139139
match call_stack_items.len() {
140140
4 => {
141141
// Build array
142-
let argv = [call_stack_items[0], call_stack_items[1], call_stack_items[2], call_stack_items[3]];
142+
let argv = [
143+
call_stack_items[0],
144+
call_stack_items[1],
145+
call_stack_items[2],
146+
call_stack_items[3],
147+
];
143148

144149
// Run process, get output
145150
match subprocess::exec_communicate(&argv, None::<&gio::Cancellable>) {
@@ -148,26 +153,34 @@ impl Processor {
148153
(None, None) => return Ok(None),
149154

150155
(None, Some(stderr_buffer)) => {
151-
println!("Process failed with error: {}", String::from_utf8_lossy(&stderr_buffer).into_owned());
152-
},
156+
println!(
157+
"Process failed with error: {}",
158+
String::from_utf8_lossy(&stderr_buffer).into_owned()
159+
);
160+
}
153161

154162
(Some(stdout_buffer), None) => {
155-
let stdout_buffer_contents = String::from_utf8_lossy(&stdout_buffer).into_owned();
163+
let stdout_buffer_contents =
164+
String::from_utf8_lossy(&stdout_buffer).into_owned();
156165

157166
return Ok(Some(self.parse(&stdout_buffer_contents)));
158-
},
167+
}
159168

160169
(Some(stdout_buffer), Some(stderr_buffer)) => {
161-
let stdout_buffer_contents = String::from_utf8_lossy(&stdout_buffer).into_owned();
170+
let stdout_buffer_contents =
171+
String::from_utf8_lossy(&stdout_buffer).into_owned();
162172

163-
println!("Process failed with error: {}", String::from_utf8_lossy(&stderr_buffer).into_owned());
173+
println!(
174+
"Process failed with error: {}",
175+
String::from_utf8_lossy(&stderr_buffer).into_owned()
176+
);
164177

165178
return Ok(Some(self.parse(&stdout_buffer_contents)));
166-
},
179+
}
167180
},
168181
Err(err) => return Err(err),
169182
};
170-
},
183+
}
171184
2 => {
172185
// Build array
173186
let argv = [call_stack_items[0], call_stack_items[1]];
@@ -179,30 +192,38 @@ impl Processor {
179192
(None, None) => return Ok(None),
180193

181194
(None, Some(stderr_buffer)) => {
182-
println!("Process failed with error: {}", String::from_utf8_lossy(&stderr_buffer).into_owned());
183-
},
195+
println!(
196+
"Process failed with error: {}",
197+
String::from_utf8_lossy(&stderr_buffer).into_owned()
198+
);
199+
}
184200

185201
(Some(stdout_buffer), None) => {
186-
let stdout_buffer_contents = String::from_utf8_lossy(&stdout_buffer).into_owned();
202+
let stdout_buffer_contents =
203+
String::from_utf8_lossy(&stdout_buffer).into_owned();
187204

188205
return Ok(Some(self.parse(&stdout_buffer_contents)));
189-
},
206+
}
190207

191208
(Some(stdout_buffer), Some(stderr_buffer)) => {
192-
let stdout_buffer_contents = String::from_utf8_lossy(&stdout_buffer).into_owned();
209+
let stdout_buffer_contents =
210+
String::from_utf8_lossy(&stdout_buffer).into_owned();
193211

194-
println!("Process failed with error: {}", String::from_utf8_lossy(&stderr_buffer).into_owned());
212+
println!(
213+
"Process failed with error: {}",
214+
String::from_utf8_lossy(&stderr_buffer).into_owned()
215+
);
195216

196217
return Ok(Some(self.parse(&stdout_buffer_contents)));
197-
},
218+
}
198219
},
199220
Err(err) => return Err(err),
200221
};
201-
},
222+
}
202223
_invalid_size => return Ok(None), // This will only occur via programmer error
203224
}
204225

205-
return Ok(None);
226+
Ok(None)
206227
}
207228

208229
/*
@@ -233,11 +254,11 @@ impl Processor {
233254
* Notes:
234255
* This function is designed to be overloaded by subclasses
235256
*/
236-
fn parse(self, input: &String) -> String {
257+
fn parse(self, input: &str) -> String {
237258
//NOTE: leaving this here for future use..
238259
//let mut output = input.replace("\n", "").to_owned();
239260
//output.push_str("-FUCK");
240261

241-
input.replace("\n", "").to_owned()
262+
input.replace("\n", "")
242263
}
243264
}

0 commit comments

Comments
 (0)