Skip to content

Commit 5b7136b

Browse files
committed
config: minor cleanup
This removes a few warnings and eliminates a little bit of unnecessary type aliasing. Signed-off-by: Paul Osborne <[email protected]>
1 parent af5c17b commit 5b7136b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/config.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ use std::fs::{self, File};
77
use std::io;
88
use std::io::prelude::*;
99
use std::path::Path;
10-
use sysfs_gpio::Direction as SysfsDirection;
10+
use sysfs_gpio;
1111
use toml;
1212

1313
#[derive(Debug, PartialEq, Clone)]
14-
pub struct Direction(pub SysfsDirection);
14+
pub struct Direction(pub sysfs_gpio::Direction);
1515

16-
impl From<SysfsDirection> for Direction {
17-
fn from(e: SysfsDirection) -> Self {
16+
impl From<sysfs_gpio::Direction> for Direction {
17+
fn from(e: sysfs_gpio::Direction) -> Self {
1818
Direction(e)
1919
}
2020
}
@@ -31,15 +31,15 @@ struct RawPinConfig {
3131
#[derive(Debug, Clone, PartialEq)]
3232
pub struct PinConfig {
3333
pub num: u64,
34-
pub direction: SysfsDirection,
34+
pub direction: sysfs_gpio::Direction,
3535
pub names: BTreeSet<String>,
3636
pub export: bool,
3737
pub active_low: bool,
3838
}
3939

4040
impl Into<PinConfig> for RawPinConfig {
4141
fn into(self) -> PinConfig {
42-
let default_direction = Direction(SysfsDirection::In);
42+
let default_direction = Direction(sysfs_gpio::Direction::In);
4343
PinConfig {
4444
num: self.num,
4545
direction: self.direction.unwrap_or(default_direction).0,
@@ -53,10 +53,10 @@ impl Into<PinConfig> for RawPinConfig {
5353
impl Decodable for Direction {
5454
fn decode<D: Decoder>(d: &mut D) -> Result<Direction, D::Error> {
5555
match try!(d.read_str()).as_str() {
56-
"in" => Ok(Direction(SysfsDirection::In)),
57-
"out" => Ok(Direction(SysfsDirection::Out)),
58-
"high" => Ok(Direction(SysfsDirection::High)),
59-
"low" => Ok(Direction(SysfsDirection::Low)),
56+
"in" => Ok(Direction(sysfs_gpio::Direction::In)),
57+
"out" => Ok(Direction(sysfs_gpio::Direction::Out)),
58+
"high" => Ok(Direction(sysfs_gpio::Direction::High)),
59+
"low" => Ok(Direction(sysfs_gpio::Direction::Low)),
6060
_ => Err(d.error("Expected one of: {in, out, high, low}")),
6161
}
6262
}
@@ -211,7 +211,7 @@ direction = "out"
211211
"#;
212212
let config = GpioConfig::from_str(configstr).unwrap();
213213
let status_led = config.pins.get(1).unwrap();
214-
let mut names = BTreeSet::from_iter(
214+
let names = BTreeSet::from_iter(
215215
vec!(String::from("status_led"),
216216
String::from("A27"),
217217
String::from("green_led")));
@@ -231,7 +231,7 @@ pins = [
231231
"#;
232232
let config = GpioConfig::from_str(configstr).unwrap();
233233
let status_led = config.pins.get(1).unwrap();
234-
let mut names = BTreeSet::from_iter(
234+
let names = BTreeSet::from_iter(
235235
vec!(String::from("status_led"),
236236
String::from("A27"),
237237
String::from("green_led")));

0 commit comments

Comments
 (0)