Skip to content

Commit 4ecc178

Browse files
committed
config: addressing comments from code review
Also, a little noise from running `cargo fmt` Signed-off-by: Paul Osborne <[email protected]>
1 parent 46c181d commit 4ecc178

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/config.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,10 @@ impl From<toml::DecodeError> for Error {
8484
impl Decodable for GpioConfig {
8585
fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error> {
8686
// Get items under the [config] header if present
87-
let symlink_root: Option<String> = d.read_struct_field("config", 0, |cfg| {
88-
cfg.read_struct_field("symlink_root",
89-
0,
90-
Decodable::decode)
91-
})
92-
.ok();
87+
let symlink_root = d.read_struct_field("config", 0, |cfg| {
88+
cfg.read_struct_field("symlink_root", 0, Decodable::decode)
89+
})
90+
.ok();
9391

9492
Ok(GpioConfig {
9593
pins: try!(d.read_struct_field("pins", 0, Decodable::decode)),
@@ -120,7 +118,6 @@ impl Decodable for PinConfig {
120118
}
121119

122120
impl PinConfig {
123-
124121
/// Get the `sysfs_gpio::Pin` to go along with this config`
125122
pub fn get_pin(&self) -> sysfs_gpio::Pin {
126123
sysfs_gpio::Pin::new(self.num)
@@ -204,7 +201,7 @@ impl GpioConfig {
204201
Ok(cfg) => {
205202
try!(cfg.validate().or_else(|e| Err(Error::from(e))));
206203
Ok(cfg)
207-
},
204+
}
208205
Err(e) => Err(Error::from(e)),
209206
}
210207
}
@@ -223,7 +220,7 @@ impl GpioConfig {
223220
pub fn get_pin(&self, name: &str) -> Option<&PinConfig> {
224221
// first, try to find pin by name
225222
if let Some(pin) = self.pins.iter().find(|p| p.names.contains(name)) {
226-
return Some(pin)
223+
return Some(pin);
227224
}
228225

229226
// Try to parse the name as a 64-bit integer and match against that

0 commit comments

Comments
 (0)