Skip to content

Commit b03064d

Browse files
committed
core: cargo fmt
Signed-off-by: Paul Osborne <osbpau@gmail.com>
1 parent 15e7e76 commit b03064d

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/lib.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub use error::Error;
2525

2626
#[derive(Debug)]
2727
pub struct PwmChip {
28-
chip: u32
28+
chip: u32,
2929
}
3030

3131
#[derive(Debug)]
@@ -55,14 +55,15 @@ impl PwmChip {
5555
try!(npwm_file.read_to_string(&mut s));
5656
match s.parse::<u32>() {
5757
Ok(n) => Ok(n),
58-
Err(_) => Err(Error::Unexpected(
59-
format!("Unexpected npwm contents: {:?}", s))),
58+
Err(_) => Err(Error::Unexpected(format!("Unexpected npwm contents: {:?}", s))),
6059
}
6160
}
6261

6362
pub fn export(&self, number: u32) -> Result<()> {
6463
// only export if not already exported
65-
if let Err(_) = fs::metadata(&format!("/sys/class/pwm/pwmchip{}/pwm{}", self.chip, number)) {
64+
if let Err(_) = fs::metadata(&format!("/sys/class/pwm/pwmchip{}/pwm{}",
65+
self.chip,
66+
number)) {
6667
let path = format!("/sys/class/pwm/pwmchip{}/export", self.chip);
6768
let mut export_file = try!(File::create(&path));
6869
let _ = export_file.write_all(format!("{}", number).as_bytes());
@@ -81,19 +82,21 @@ impl PwmChip {
8182
}
8283

8384
impl Pwm {
84-
8585
/// Create a new Pwm wiht the provided chip/number
8686
///
8787
/// This function does not export the Pwm pin
8888
pub fn new(chip: u32, number: u32) -> Result<Pwm> {
8989
let chip: PwmChip = try!(PwmChip::new(chip));
90-
Ok(Pwm { chip: chip, number: number })
90+
Ok(Pwm {
91+
chip: chip,
92+
number: number,
93+
})
9194
}
9295

9396
/// Run a closure with the GPIO exported
9497
#[inline]
95-
pub fn with_exported<F>(&self, closure: F) -> Result<()> where
96-
F: FnOnce() -> Result<()>
98+
pub fn with_exported<F>(&self, closure: F) -> Result<()>
99+
where F: FnOnce() -> Result<()>
97100
{
98101
try!(self.export());
99102
match closure() {
@@ -133,12 +136,12 @@ impl Pwm {
133136
///
134137
/// Value is in nanoseconds and must be less than the period.
135138
pub fn set_duty_cycle_ns(&self, duty_cycle_ns: u32) -> Result<()> {
139+
136140
Ok(())
137141
}
138142

139143
/// The period of the PWM signal in Nanoseconds
140144
pub fn set_period_ns(&self, period_ns: u32) -> Result<()> {
141145
Ok(())
142146
}
143-
144147
}

0 commit comments

Comments
 (0)