3434//! ```
3535//!
3636
37-
3837#[ allow( deprecated) ]
3938use super :: v1;
4039use 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 >
4847where
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 >
6564where
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 >
7877where
79- T : v2:: OutputPin < Error = E > ,
78+ T : v2:: OutputPin < Error = E > ,
8079 E : core:: fmt:: Debug ,
8180{
8281 fn set_low ( & mut self ) {
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 >
9695where
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 >
118117where
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 >
131129where
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 >
145143where
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}
0 commit comments