Skip to content

Commit c3d4922

Browse files
Make the digtal::v1::InputPin proven
Side effect: make the compat traits proven
1 parent 6369969 commit c3d4922

File tree

3 files changed

+1
-29
lines changed

3 files changed

+1
-29
lines changed

src/digital/v1.rs

-3
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,8 @@ pub mod toggleable {
131131

132132
/// Single digital input pin
133133
///
134-
/// *This trait is available if embedded-hal is built with the `"unproven"` feature.*
135-
///
136134
/// *This version of the trait is now deprecated. Please use the new `InputPin` trait in
137135
/// `digital::v2::InputPin`*.
138-
#[cfg(feature = "unproven")]
139136
pub trait InputPin {
140137
/// Is the input pin high?
141138
fn is_high(&self) -> bool;

src/digital/v1_compat.rs

-16
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,10 @@ where
108108

109109
/// Wrapper to allow fallible `v2::InputPin` traits to be converted to `v1::InputPin` traits
110110
/// where errors will panic.
111-
///
112-
/// Available behind `"unproven"` feature because `v1::InputPin` is
113-
#[cfg(feature = "unproven")]
114111
pub struct OldInputPin<T> {
115112
pin: T,
116113
}
117114

118-
#[cfg(feature = "unproven")]
119115
impl <T, E> OldInputPin<T>
120116
where
121117
T: v2::OutputPin<Error=E>,
@@ -128,7 +124,6 @@ where
128124

129125
}
130126

131-
#[cfg(feature = "unproven")]
132127
impl <T, E> From<T> for OldInputPin<T>
133128
where
134129
T: v2::InputPin<Error=E>,
@@ -141,9 +136,6 @@ where
141136

142137
/// Implementation of `v1::InputPin` trait for `v2::InputPin` fallible pins
143138
/// where errors will panic.
144-
///
145-
/// Available behind `"unproven"` feature because `v1::InputPin` is
146-
#[cfg(feature = "unproven")]
147139
#[allow(deprecated)]
148140
impl <T, E> v1::InputPin for OldInputPin<T>
149141
where
@@ -228,15 +220,12 @@ mod tests {
228220
o.set_high();
229221
}
230222

231-
#[cfg(feature = "unproven")]
232223
use crate::digital::v1::InputPin;
233224

234-
#[cfg(feature = "unproven")]
235225
struct NewInputPinImpl {
236226
state: Result<bool, ()>,
237227
}
238228

239-
#[cfg(feature = "unproven")]
240229
impl v2::InputPin for NewInputPinImpl {
241230
type Error = ();
242231

@@ -248,13 +237,11 @@ mod tests {
248237
}
249238
}
250239

251-
#[cfg(feature = "unproven")]
252240
#[allow(deprecated)]
253241
struct OldInputPinConsumer<T: v1::InputPin> {
254242
_pin: T,
255243
}
256244

257-
#[cfg(feature = "unproven")]
258245
#[allow(deprecated)]
259246
impl <T>OldInputPinConsumer<T>
260247
where T: v1::InputPin
@@ -264,14 +251,12 @@ mod tests {
264251
}
265252
}
266253

267-
#[cfg(feature = "unproven")]
268254
#[test]
269255
fn v1_v2_input_explicit() {
270256
let i = NewInputPinImpl{state: Ok(false)};
271257
let _c: OldInputPinConsumer<OldInputPin<_>> = OldInputPinConsumer::new(i.into());
272258
}
273259

274-
#[cfg(feature = "unproven")]
275260
#[test]
276261
fn v1_v2_input_state() {
277262
let i: OldInputPin<_> = NewInputPinImpl{state: Ok(false)}.into();
@@ -280,7 +265,6 @@ mod tests {
280265
assert_eq!(i.is_high(), false);
281266
}
282267

283-
#[cfg(feature = "unproven")]
284268
#[test]
285269
#[should_panic]
286270
fn v1_v2_input_panic() {

src/digital/v2_compat.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ where
7676
impl<T> v2::toggleable::Default for T where T: v1::toggleable::Default {}
7777

7878
/// Implementation of fallible `v2::InputPin` for `v1::InputPin` digital traits
79-
///
80-
/// Available behind `"unproven"` feature because `v1::InputPin` is
81-
#[cfg(feature = "unproven")]
8279
#[allow(deprecated)]
8380
impl <T> v2::InputPin for T
8481
where
@@ -183,13 +180,11 @@ mod tests {
183180
assert_eq!(o.state, false);
184181
}
185182

186-
#[cfg(feature = "unproven")]
187183
#[allow(deprecated)]
188184
struct OldInputPinImpl {
189185
state: bool
190186
}
191187

192-
#[cfg(feature = "unproven")]
193188
#[allow(deprecated)]
194189
impl v1::InputPin for OldInputPinImpl {
195190
fn is_low(&self) -> bool {
@@ -200,32 +195,28 @@ mod tests {
200195
}
201196
}
202197

203-
#[cfg(feature = "unproven")]
204198
struct NewInputPinConsumer<T: v2::InputPin> {
205199
_pin: T,
206200
}
207201

208-
#[cfg(feature = "unproven")]
209202
impl <T>NewInputPinConsumer<T>
210203
where T: v2::InputPin {
211204
pub fn new(pin: T) -> NewInputPinConsumer<T> {
212205
NewInputPinConsumer{ _pin: pin }
213206
}
214207
}
215208

216-
#[cfg(feature = "unproven")]
217209
#[test]
218210
fn v2_v1_input_implicit() {
219211
let i = OldInputPinImpl{state: false};
220212
let _c = NewInputPinConsumer::new(i);
221213
}
222214

223-
#[cfg(feature = "unproven")]
224215
#[test]
225216
fn v2_v1_input_state() {
226217
let mut i = OldInputPinImpl{state: false};
227218

228219
assert_eq!(v2::InputPin::is_high(&mut i).unwrap(), false);
229220
assert_eq!(v2::InputPin::is_low(&mut i).unwrap(), true);
230221
}
231-
}
222+
}

0 commit comments

Comments
 (0)