34
34
//! ```
35
35
//!
36
36
37
-
38
37
#[ allow( deprecated) ]
39
38
use super :: v1;
40
39
use super :: v2;
@@ -44,14 +43,14 @@ pub struct OldOutputPin<T> {
44
43
pin : T ,
45
44
}
46
45
47
- impl < T , E > OldOutputPin < T >
46
+ impl < T , E > OldOutputPin < T >
48
47
where
49
- T : v2:: OutputPin < Error = E > ,
48
+ T : v2:: OutputPin < Error = E > ,
50
49
E : core:: fmt:: Debug ,
51
50
{
52
51
/// Create a new OldOutputPin wrapper around a `v2::OutputPin`
53
52
pub fn new ( pin : T ) -> Self {
54
- Self { pin}
53
+ Self { pin }
55
54
}
56
55
57
56
/// Fetch a reference to the inner `v2::OutputPin` impl
@@ -61,22 +60,22 @@ where
61
60
}
62
61
}
63
62
64
- impl < T , E > From < T > for OldOutputPin < T >
63
+ impl < T , E > From < T > for OldOutputPin < T >
65
64
where
66
- T : v2:: OutputPin < Error = E > ,
65
+ T : v2:: OutputPin < Error = E > ,
67
66
E : core:: fmt:: Debug ,
68
67
{
69
68
fn from ( pin : T ) -> Self {
70
- OldOutputPin { pin}
69
+ OldOutputPin { pin }
71
70
}
72
71
}
73
72
74
73
/// Implementation of `v1::OutputPin` trait for fallible `v2::OutputPin` output pins
75
74
/// where errors will panic.
76
75
#[ allow( deprecated) ]
77
- impl < T , E > v1:: OutputPin for OldOutputPin < T >
76
+ impl < T , E > v1:: OutputPin for OldOutputPin < T >
78
77
where
79
- T : v2:: OutputPin < Error = E > ,
78
+ T : v2:: OutputPin < Error = E > ,
80
79
E : core:: fmt:: Debug ,
81
80
{
82
81
fn set_low ( & mut self ) {
92
91
/// where errors will panic.
93
92
#[ cfg( feature = "unproven" ) ]
94
93
#[ allow( deprecated) ]
95
- impl < T , E > v1:: StatefulOutputPin for OldOutputPin < T >
94
+ impl < T , E > v1:: StatefulOutputPin for OldOutputPin < T >
96
95
where
97
- T : v2:: StatefulOutputPin < Error = E > ,
96
+ T : v2:: StatefulOutputPin < Error = E > ,
98
97
E : core:: fmt:: Debug ,
99
98
{
100
99
fn is_set_low ( & self ) -> bool {
@@ -114,36 +113,35 @@ pub struct OldInputPin<T> {
114
113
}
115
114
116
115
#[ cfg( feature = "unproven" ) ]
117
- impl < T , E > OldInputPin < T >
116
+ impl < T , E > OldInputPin < T >
118
117
where
119
- T : v2:: InputPin < Error = E > ,
118
+ T : v2:: InputPin < Error = E > ,
120
119
E : core:: fmt:: Debug ,
121
120
{
122
121
/// Create an `OldInputPin` wrapper around a `v2::InputPin`.
123
122
pub fn new ( pin : T ) -> Self {
124
- Self { pin}
123
+ Self { pin }
125
124
}
126
-
127
125
}
128
126
129
127
#[ cfg( feature = "unproven" ) ]
130
- impl < T , E > From < T > for OldInputPin < T >
128
+ impl < T , E > From < T > for OldInputPin < T >
131
129
where
132
- T : v2:: InputPin < Error = E > ,
130
+ T : v2:: InputPin < Error = E > ,
133
131
E : core:: fmt:: Debug ,
134
132
{
135
133
fn from ( pin : T ) -> Self {
136
- OldInputPin { pin}
134
+ OldInputPin { pin }
137
135
}
138
136
}
139
137
140
138
/// Implementation of `v1::InputPin` trait for `v2::InputPin` fallible pins
141
139
/// where errors will panic.
142
140
#[ cfg( feature = "unproven" ) ]
143
141
#[ allow( deprecated) ]
144
- impl < T , E > v1:: InputPin for OldInputPin < T >
142
+ impl < T , E > v1:: InputPin for OldInputPin < T >
145
143
where
146
- T : v2:: InputPin < Error = E > ,
144
+ T : v2:: InputPin < Error = E > ,
147
145
E : core:: fmt:: Debug ,
148
146
{
149
147
fn is_low ( & self ) -> bool {
@@ -169,7 +167,7 @@ mod tests {
169
167
#[ derive( Clone ) ]
170
168
struct NewOutputPinImpl {
171
169
state : bool ,
172
- res : Result < ( ) , ( ) >
170
+ res : Result < ( ) , ( ) > ,
173
171
}
174
172
175
173
impl v2:: OutputPin for NewOutputPinImpl {
@@ -179,7 +177,7 @@ mod tests {
179
177
self . state = false ;
180
178
self . res
181
179
}
182
- fn set_high ( & mut self ) -> Result < ( ) , Self :: Error > {
180
+ fn set_high ( & mut self ) -> Result < ( ) , Self :: Error > {
183
181
self . state = true ;
184
182
self . res
185
183
}
@@ -191,23 +189,31 @@ mod tests {
191
189
}
192
190
193
191
#[ allow( deprecated) ]
194
- impl < T > OldOutputPinConsumer < T >
195
- where T : v1:: OutputPin
192
+ impl < T > OldOutputPinConsumer < T >
193
+ where
194
+ T : v1:: OutputPin ,
196
195
{
197
196
pub fn new ( pin : T ) -> OldOutputPinConsumer < T > {
198
- OldOutputPinConsumer { _pin : pin }
197
+ OldOutputPinConsumer { _pin : pin }
199
198
}
200
199
}
201
200
202
201
#[ test]
203
202
fn v1_v2_output_explicit ( ) {
204
- let i = NewOutputPinImpl { state : false , res : Ok ( ( ) ) } ;
203
+ let i = NewOutputPinImpl {
204
+ state : false ,
205
+ res : Ok ( ( ) ) ,
206
+ } ;
205
207
let _c: OldOutputPinConsumer < OldOutputPin < _ > > = OldOutputPinConsumer :: new ( i. into ( ) ) ;
206
208
}
207
209
208
210
#[ test]
209
211
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 ( ) ;
211
217
212
218
o. set_high ( ) ;
213
219
assert_eq ! ( o. inner( ) . state, true ) ;
@@ -219,7 +225,11 @@ mod tests {
219
225
#[ test]
220
226
#[ should_panic]
221
227
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 ( ) ;
223
233
224
234
o. set_high ( ) ;
225
235
}
@@ -239,7 +249,7 @@ mod tests {
239
249
fn is_low ( & self ) -> Result < bool , Self :: Error > {
240
250
self . state . map ( |v| v == false )
241
251
}
242
- fn is_high ( & self ) -> Result < bool , Self :: Error > {
252
+ fn is_high ( & self ) -> Result < bool , Self :: Error > {
243
253
self . state . map ( |v| v == true )
244
254
}
245
255
}
@@ -252,25 +262,26 @@ mod tests {
252
262
253
263
#[ cfg( feature = "unproven" ) ]
254
264
#[ allow( deprecated) ]
255
- impl < T > OldInputPinConsumer < T >
256
- where T : v1:: InputPin
265
+ impl < T > OldInputPinConsumer < T >
266
+ where
267
+ T : v1:: InputPin ,
257
268
{
258
269
pub fn new ( pin : T ) -> OldInputPinConsumer < T > {
259
- OldInputPinConsumer { _pin : pin }
270
+ OldInputPinConsumer { _pin : pin }
260
271
}
261
272
}
262
273
263
274
#[ cfg( feature = "unproven" ) ]
264
275
#[ test]
265
276
fn v1_v2_input_explicit ( ) {
266
- let i = NewInputPinImpl { state : Ok ( false ) } ;
277
+ let i = NewInputPinImpl { state : Ok ( false ) } ;
267
278
let _c: OldInputPinConsumer < OldInputPin < _ > > = OldInputPinConsumer :: new ( i. into ( ) ) ;
268
279
}
269
280
270
281
#[ cfg( feature = "unproven" ) ]
271
282
#[ test]
272
283
fn v1_v2_input_state ( ) {
273
- let i: OldInputPin < _ > = NewInputPinImpl { state : Ok ( false ) } . into ( ) ;
284
+ let i: OldInputPin < _ > = NewInputPinImpl { state : Ok ( false ) } . into ( ) ;
274
285
275
286
assert_eq ! ( i. is_low( ) , true ) ;
276
287
assert_eq ! ( i. is_high( ) , false ) ;
@@ -280,9 +291,8 @@ mod tests {
280
291
#[ test]
281
292
#[ should_panic]
282
293
fn v1_v2_input_panic ( ) {
283
- let i: OldInputPin < _ > = NewInputPinImpl { state : Err ( ( ) ) } . into ( ) ;
294
+ let i: OldInputPin < _ > = NewInputPinImpl { state : Err ( ( ) ) } . into ( ) ;
284
295
285
296
i. is_low ( ) ;
286
297
}
287
-
288
298
}
0 commit comments