Skip to content

Commit cd8f60f

Browse files
committed
Ran cargo +nightly fmt.
1 parent db799cf commit cd8f60f

File tree

5 files changed

+29
-39
lines changed

5 files changed

+29
-39
lines changed

examples/get_all.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,39 @@ use sensehat::SenseHat;
44

55
fn main() {
66
let mut sense_hat = SenseHat::new().expect("Couldn't create Sense Hat object");
7-
let temp = sense_hat.get_temperature_from_humidity().expect(
8-
"Couldn't get temp",
9-
);
7+
let temp = sense_hat
8+
.get_temperature_from_humidity()
9+
.expect("Couldn't get temp");
1010
println!("It's {} on the humidity sensor", temp);
11-
let temp = sense_hat.get_temperature_from_pressure().expect(
12-
"Couldn't get temp",
13-
);
11+
let temp = sense_hat
12+
.get_temperature_from_pressure()
13+
.expect("Couldn't get temp");
1414
println!("It's {} on the pressure sensor", temp);
1515
let rh = sense_hat.get_humidity().expect("Couldn't get rh");
1616
println!("It's {} relative humidity", rh);
1717
let pressure = sense_hat.get_pressure().expect("Couldn't get pressure");
1818
println!("The pressure is {}", pressure);
1919
loop {
20-
let orientation = sense_hat.get_orientation().expect(
21-
"Couldn't get orientation",
22-
);
20+
let orientation = sense_hat
21+
.get_orientation()
22+
.expect("Couldn't get orientation");
2323
println!(
2424
"Fusion orientation: {}, {}, {}",
25-
orientation.roll,
26-
orientation.pitch,
27-
orientation.yaw
25+
orientation.roll, orientation.pitch, orientation.yaw
2826
);
2927
if let Ok(heading) = sense_hat.get_compass() {
3028
println!("Compass heading : {}", heading);
3129
}
3230
if let Ok(orientation) = sense_hat.get_gyro() {
3331
println!(
3432
"Gyro orientation : {}, {}, {}",
35-
orientation.roll,
36-
orientation.pitch,
37-
orientation.yaw
33+
orientation.roll, orientation.pitch, orientation.yaw
3834
);
3935
}
4036
if let Ok(orientation) = sense_hat.get_accel() {
4137
println!(
4238
"Accel orientation: {}, {}, {}",
43-
orientation.roll,
44-
orientation.pitch,
45-
orientation.yaw
39+
orientation.roll, orientation.pitch, orientation.yaw
4640
);
4741
}
4842
::std::thread::sleep(::std::time::Duration::from_millis(250));

src/hts221.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,10 @@ where
9999
}
100100

101101
pub fn get_relative_humidity_percent(&mut self) -> Result<f64, T::Error> {
102-
self.get_relative_humidity().and_then(|c| {
103-
Ok((c as f64 * self.hum_m) + self.hum_c)
104-
})
102+
self.get_relative_humidity()
103+
.and_then(|c| Ok((c as f64 * self.hum_m) + self.hum_c))
105104
}
106105

107-
108106
pub fn get_temperature(&mut self) -> Result<i16, T::Error> {
109107
let mut buf = [0u8; 2];
110108
buf[0] = self.i2cdev.smbus_read_byte_data(REG_TEMP_OUT_L)?;
@@ -113,8 +111,7 @@ where
113111
}
114112

115113
pub fn get_temperature_celcius(&mut self) -> Result<f64, T::Error> {
116-
self.get_temperature().and_then(|c| {
117-
Ok((c as f64 * self.temp_m) + self.temp_c)
118-
})
114+
self.get_temperature()
115+
.and_then(|c| Ok((c as f64 * self.temp_m) + self.temp_c))
119116
}
120117
}

src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ impl<'a> SenseHat<'a> {
9090
pub fn get_temperature_from_pressure(&mut self) -> SenseHatResult<Temperature> {
9191
let status = self.pressure_chip.status()?;
9292
if (status & 1) != 0 {
93-
Ok(Temperature::from_celsius(
94-
self.pressure_chip.get_temp_celcius()?,
95-
))
93+
Ok(Temperature::from_celsius(self.pressure_chip.get_temp_celcius()?))
9694
} else {
9795
Err(SenseHatError::NotReady)
9896
}
@@ -102,9 +100,7 @@ impl<'a> SenseHat<'a> {
102100
pub fn get_pressure(&mut self) -> SenseHatResult<Pressure> {
103101
let status = self.pressure_chip.status()?;
104102
if (status & 2) != 0 {
105-
Ok(Pressure::from_hectopascals(
106-
self.pressure_chip.get_pressure_hpa()?,
107-
))
103+
Ok(Pressure::from_hectopascals(self.pressure_chip.get_pressure_hpa()?))
108104
} else {
109105
Err(SenseHatError::NotReady)
110106
}
@@ -203,7 +199,9 @@ impl From<lsm9ds1::Error> for SenseHatError {
203199

204200
impl Angle {
205201
pub fn from_radians(rad: f64) -> Angle {
206-
Angle { value: radians_to_degrees(rad) }
202+
Angle {
203+
value: radians_to_degrees(rad),
204+
}
207205
}
208206

209207
pub fn as_radians(&self) -> f64 {

src/lsm9ds1.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! a C wrapper of the RTIMULib C++ API. We then call that unsafe C wrapper
1010
//! here, ensuring that any memory allocations were undone on drop.
1111
12-
use super::{Orientation, Angle};
12+
use super::{Angle, Orientation};
1313
use libc;
1414

1515
enum RTIMULibContext {}
@@ -37,7 +37,6 @@ struct COrientation {
3737
z: libc::c_double,
3838
}
3939

40-
4140
#[derive(Debug)]
4241
pub enum Error {
4342
RTIMULibError,
@@ -47,11 +46,9 @@ pub struct Lsm9ds1<'a> {
4746
rtimulib_ref: &'a mut RTIMULibContext,
4847
}
4948

50-
5149
impl<'a> Lsm9ds1<'a> {
5250
/// Uses the RTIMULib library.
5351
pub fn new() -> Result<Lsm9ds1<'a>, Error> {
54-
5552
let ctx_ref = unsafe {
5653
let ctx_p = rtimulib_wrapper_create();
5754
if ctx_p.is_null() {
@@ -60,7 +57,9 @@ impl<'a> Lsm9ds1<'a> {
6057
&mut *ctx_p
6158
};
6259

63-
Ok(Lsm9ds1 { rtimulib_ref: ctx_ref })
60+
Ok(Lsm9ds1 {
61+
rtimulib_ref: ctx_ref,
62+
})
6463
}
6564

6665
/// Make the IMU do some work. When this function returns true, the IMU

src/lsm9ds1_dummy.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! This is just a placeholder so the the docs build without RTIMULib.
44
5-
use super::{Orientation, Angle};
5+
use super::{Angle, Orientation};
66
use std::marker::PhantomData;
77

88
enum RTIMULibContext {}
@@ -19,7 +19,9 @@ pub struct Lsm9ds1<'a> {
1919
impl<'a> Lsm9ds1<'a> {
2020
/// Uses the RTIMULib library.
2121
pub fn new() -> Result<Lsm9ds1<'a>, Error> {
22-
Ok(Lsm9ds1 { phantom: PhantomData })
22+
Ok(Lsm9ds1 {
23+
phantom: PhantomData,
24+
})
2325
}
2426

2527
/// Make the IMU do some work. When this function returns true, the IMU

0 commit comments

Comments
 (0)