Skip to content

Commit c48b2a3

Browse files
committed
Code formatting
1 parent 0711f6e commit c48b2a3

File tree

9 files changed

+107
-92
lines changed

9 files changed

+107
-92
lines changed

src/blocking/i2c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,6 @@ pub trait WriteIterRead {
124124
bytes: B,
125125
buffer: &mut [u8],
126126
) -> Result<(), Self::Error>
127-
where
127+
where
128128
B: IntoIterator<Item = u8>;
129129
}

src/digital/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
//! Digital I/O
22
//!
3-
//!
3+
//!
44
//!
55
66
// Deprecated / infallible traits
7-
#[deprecated(since = "0.2.2", note = "Deprecated because the methods cannot return errors. \
8-
Users should use the traits in digital::v2.")]
7+
#[deprecated(
8+
since = "0.2.2",
9+
note = "Deprecated because the methods cannot return errors. \
10+
Users should use the traits in digital::v2."
11+
)]
912
pub mod v1;
1013

1114
// New / fallible traits
@@ -22,4 +25,3 @@ pub mod v2_compat;
2225
// Re-export old traits so this isn't a breaking change
2326
#[allow(deprecated)]
2427
pub use self::v1::*;
25-

src/digital/v1_compat.rs

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
//! ```
3535
//!
3636
37-
3837
#[allow(deprecated)]
3938
use super::v1;
4039
use super::v2;
@@ -44,14 +43,14 @@ pub struct OldOutputPin<T> {
4443
pin: T,
4544
}
4645

47-
impl <T, E> OldOutputPin<T>
46+
impl<T, E> OldOutputPin<T>
4847
where
49-
T: v2::OutputPin<Error=E>,
48+
T: v2::OutputPin<Error = E>,
5049
E: core::fmt::Debug,
5150
{
5251
/// Create a new OldOutputPin wrapper around a `v2::OutputPin`
5352
pub fn new(pin: T) -> Self {
54-
Self{pin}
53+
Self { pin }
5554
}
5655

5756
/// Fetch a reference to the inner `v2::OutputPin` impl
@@ -61,22 +60,22 @@ where
6160
}
6261
}
6362

64-
impl <T, E> From<T> for OldOutputPin<T>
63+
impl<T, E> From<T> for OldOutputPin<T>
6564
where
66-
T: v2::OutputPin<Error=E>,
65+
T: v2::OutputPin<Error = E>,
6766
E: core::fmt::Debug,
6867
{
6968
fn from(pin: T) -> Self {
70-
OldOutputPin{pin}
69+
OldOutputPin { pin }
7170
}
7271
}
7372

7473
/// Implementation of `v1::OutputPin` trait for fallible `v2::OutputPin` output pins
7574
/// where errors will panic.
7675
#[allow(deprecated)]
77-
impl <T, E> v1::OutputPin for OldOutputPin<T>
76+
impl<T, E> v1::OutputPin for OldOutputPin<T>
7877
where
79-
T: v2::OutputPin<Error=E>,
78+
T: v2::OutputPin<Error = E>,
8079
E: core::fmt::Debug,
8180
{
8281
fn set_low(&mut self) {
@@ -92,9 +91,9 @@ where
9291
/// where errors will panic.
9392
#[cfg(feature = "unproven")]
9493
#[allow(deprecated)]
95-
impl <T, E> v1::StatefulOutputPin for OldOutputPin<T>
94+
impl<T, E> v1::StatefulOutputPin for OldOutputPin<T>
9695
where
97-
T: v2::StatefulOutputPin<Error=E>,
96+
T: v2::StatefulOutputPin<Error = E>,
9897
E: core::fmt::Debug,
9998
{
10099
fn is_set_low(&self) -> bool {
@@ -114,36 +113,35 @@ pub struct OldInputPin<T> {
114113
}
115114

116115
#[cfg(feature = "unproven")]
117-
impl <T, E> OldInputPin<T>
116+
impl<T, E> OldInputPin<T>
118117
where
119-
T: v2::InputPin<Error=E>,
118+
T: v2::InputPin<Error = E>,
120119
E: core::fmt::Debug,
121120
{
122121
/// Create an `OldInputPin` wrapper around a `v2::InputPin`.
123122
pub fn new(pin: T) -> Self {
124-
Self{pin}
123+
Self { pin }
125124
}
126-
127125
}
128126

129127
#[cfg(feature = "unproven")]
130-
impl <T, E> From<T> for OldInputPin<T>
128+
impl<T, E> From<T> for OldInputPin<T>
131129
where
132-
T: v2::InputPin<Error=E>,
130+
T: v2::InputPin<Error = E>,
133131
E: core::fmt::Debug,
134132
{
135133
fn from(pin: T) -> Self {
136-
OldInputPin{pin}
134+
OldInputPin { pin }
137135
}
138136
}
139137

140138
/// Implementation of `v1::InputPin` trait for `v2::InputPin` fallible pins
141139
/// where errors will panic.
142140
#[cfg(feature = "unproven")]
143141
#[allow(deprecated)]
144-
impl <T, E> v1::InputPin for OldInputPin<T>
142+
impl<T, E> v1::InputPin for OldInputPin<T>
145143
where
146-
T: v2::InputPin<Error=E>,
144+
T: v2::InputPin<Error = E>,
147145
E: core::fmt::Debug,
148146
{
149147
fn is_low(&self) -> bool {
@@ -169,7 +167,7 @@ mod tests {
169167
#[derive(Clone)]
170168
struct NewOutputPinImpl {
171169
state: bool,
172-
res: Result<(), ()>
170+
res: Result<(), ()>,
173171
}
174172

175173
impl v2::OutputPin for NewOutputPinImpl {
@@ -179,7 +177,7 @@ mod tests {
179177
self.state = false;
180178
self.res
181179
}
182-
fn set_high(&mut self) -> Result<(), Self::Error>{
180+
fn set_high(&mut self) -> Result<(), Self::Error> {
183181
self.state = true;
184182
self.res
185183
}
@@ -191,23 +189,31 @@ mod tests {
191189
}
192190

193191
#[allow(deprecated)]
194-
impl <T>OldOutputPinConsumer<T>
195-
where T: v1::OutputPin
192+
impl<T> OldOutputPinConsumer<T>
193+
where
194+
T: v1::OutputPin,
196195
{
197196
pub fn new(pin: T) -> OldOutputPinConsumer<T> {
198-
OldOutputPinConsumer{ _pin: pin }
197+
OldOutputPinConsumer { _pin: pin }
199198
}
200199
}
201200

202201
#[test]
203202
fn v1_v2_output_explicit() {
204-
let i = NewOutputPinImpl{state: false, res: Ok(())};
203+
let i = NewOutputPinImpl {
204+
state: false,
205+
res: Ok(()),
206+
};
205207
let _c: OldOutputPinConsumer<OldOutputPin<_>> = OldOutputPinConsumer::new(i.into());
206208
}
207209

208210
#[test]
209211
fn v1_v2_output_state() {
210-
let mut o: OldOutputPin<_> = NewOutputPinImpl{state: false, res: Ok(())}.into();
212+
let mut o: OldOutputPin<_> = NewOutputPinImpl {
213+
state: false,
214+
res: Ok(()),
215+
}
216+
.into();
211217

212218
o.set_high();
213219
assert_eq!(o.inner().state, true);
@@ -219,7 +225,11 @@ mod tests {
219225
#[test]
220226
#[should_panic]
221227
fn v1_v2_output_panic() {
222-
let mut o: OldOutputPin<_> = NewOutputPinImpl{state: false, res: Err(())}.into();
228+
let mut o: OldOutputPin<_> = NewOutputPinImpl {
229+
state: false,
230+
res: Err(()),
231+
}
232+
.into();
223233

224234
o.set_high();
225235
}
@@ -239,7 +249,7 @@ mod tests {
239249
fn is_low(&self) -> Result<bool, Self::Error> {
240250
self.state.map(|v| v == false)
241251
}
242-
fn is_high(&self) -> Result<bool, Self::Error>{
252+
fn is_high(&self) -> Result<bool, Self::Error> {
243253
self.state.map(|v| v == true)
244254
}
245255
}
@@ -252,25 +262,26 @@ mod tests {
252262

253263
#[cfg(feature = "unproven")]
254264
#[allow(deprecated)]
255-
impl <T>OldInputPinConsumer<T>
256-
where T: v1::InputPin
265+
impl<T> OldInputPinConsumer<T>
266+
where
267+
T: v1::InputPin,
257268
{
258269
pub fn new(pin: T) -> OldInputPinConsumer<T> {
259-
OldInputPinConsumer{ _pin: pin }
270+
OldInputPinConsumer { _pin: pin }
260271
}
261272
}
262273

263274
#[cfg(feature = "unproven")]
264275
#[test]
265276
fn v1_v2_input_explicit() {
266-
let i = NewInputPinImpl{state: Ok(false)};
277+
let i = NewInputPinImpl { state: Ok(false) };
267278
let _c: OldInputPinConsumer<OldInputPin<_>> = OldInputPinConsumer::new(i.into());
268279
}
269280

270281
#[cfg(feature = "unproven")]
271282
#[test]
272283
fn v1_v2_input_state() {
273-
let i: OldInputPin<_> = NewInputPinImpl{state: Ok(false)}.into();
284+
let i: OldInputPin<_> = NewInputPinImpl { state: Ok(false) }.into();
274285

275286
assert_eq!(i.is_low(), true);
276287
assert_eq!(i.is_high(), false);
@@ -280,9 +291,8 @@ mod tests {
280291
#[test]
281292
#[should_panic]
282293
fn v1_v2_input_panic() {
283-
let i: OldInputPin<_> = NewInputPinImpl{state: Err(())}.into();
294+
let i: OldInputPin<_> = NewInputPinImpl { state: Err(()) }.into();
284295

285296
i.is_low();
286297
}
287-
288298
}

src/digital/v2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub trait OutputPin {
2424
///
2525
/// *This trait is available if embedded-hal is built with the `"unproven"` feature.*
2626
#[cfg(feature = "unproven")]
27-
pub trait StatefulOutputPin : OutputPin {
27+
pub trait StatefulOutputPin: OutputPin {
2828
/// Is the pin in drive high mode?
2929
///
3030
/// *NOTE* this does *not* read the electrical state of the pin

0 commit comments

Comments
 (0)