Skip to content

Commit 6876816

Browse files
committed
Some trivial simplifications
1 parent 8cfd190 commit 6876816

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn pwm_file_parse<T: FromStr>(chip: &PwmChip, pin: u32, name: &str) -> Result<T>
7474
impl PwmChip {
7575
pub fn new(number: u32) -> Result<PwmChip> {
7676
fs::metadata(&format!("/sys/class/pwm/pwmchip{}", number))?;
77-
Ok(PwmChip { number: number })
77+
Ok(PwmChip { number })
7878
}
7979

8080
pub fn count(&self) -> Result<u32> {
@@ -127,10 +127,7 @@ impl Pwm {
127127
/// This function does not export the Pwm pin
128128
pub fn new(chip: u32, number: u32) -> Result<Pwm> {
129129
let chip: PwmChip = PwmChip::new(chip)?;
130-
Ok(Pwm {
131-
chip: chip,
132-
number: number,
133-
})
130+
Ok(Pwm { chip, number })
134131
}
135132

136133
/// Run a closure with the GPIO exported
@@ -240,8 +237,9 @@ impl Pwm {
240237
"normal" => Ok(Polarity::Normal),
241238
"inversed" => Ok(Polarity::Inverse),
242239
_ => Err(Error::Unexpected(format!(
243-
"Unexpected polarity file contents: {:?}",
244-
s))),
240+
"Unexpected polarity file contents: {:?}",
241+
s
242+
))),
245243
}
246244
}
247245
}

0 commit comments

Comments
 (0)