Skip to content

Commit 26b5b18

Browse files
Make the digtal::v1::InputPin proven
Side effect: make the compat traits proven
1 parent 1dad061 commit 26b5b18

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
@@ -178,13 +175,11 @@ mod tests {
178175
assert_eq!(o.state, false);
179176
}
180177

181-
#[cfg(feature = "unproven")]
182178
#[allow(deprecated)]
183179
struct OldInputPinImpl {
184180
state: bool
185181
}
186182

187-
#[cfg(feature = "unproven")]
188183
#[allow(deprecated)]
189184
impl v1::InputPin for OldInputPinImpl {
190185
fn is_low(&self) -> bool {
@@ -195,32 +190,28 @@ mod tests {
195190
}
196191
}
197192

198-
#[cfg(feature = "unproven")]
199193
struct NewInputPinConsumer<T: v2::InputPin> {
200194
_pin: T,
201195
}
202196

203-
#[cfg(feature = "unproven")]
204197
impl <T>NewInputPinConsumer<T>
205198
where T: v2::InputPin {
206199
pub fn new(pin: T) -> NewInputPinConsumer<T> {
207200
NewInputPinConsumer{ _pin: pin }
208201
}
209202
}
210203

211-
#[cfg(feature = "unproven")]
212204
#[test]
213205
fn v2_v1_input_implicit() {
214206
let i = OldInputPinImpl{state: false};
215207
let _c = NewInputPinConsumer::new(i);
216208
}
217209

218-
#[cfg(feature = "unproven")]
219210
#[test]
220211
fn v2_v1_input_state() {
221212
let mut i = OldInputPinImpl{state: false};
222213

223214
assert_eq!(v2::InputPin::is_high(&mut i).unwrap(), false);
224215
assert_eq!(v2::InputPin::is_low(&mut i).unwrap(), true);
225216
}
226-
}
217+
}

0 commit comments

Comments
 (0)