Skip to content

Commit 7479ba9

Browse files
authored
Merge pull request #547 from Dirbaio/gpio-mut
gpio: require `&mut self` in `InputPin` and `StatefulOutputPin`.
2 parents 635cf86 + fc2cc4c commit 7479ba9

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

embedded-hal/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
No unreleased changes
10+
- gpio: require `&mut self` in `InputPin` and `StatefulOutputPin`.
1111

1212
## [v1.0.0-rc.2] - 2023-11-28
1313

embedded-hal/src/digital.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,22 @@ pub trait StatefulOutputPin: OutputPin {
169169
/// Is the pin in drive high mode?
170170
///
171171
/// *NOTE* this does *not* read the electrical state of the pin.
172-
fn is_set_high(&self) -> Result<bool, Self::Error>;
172+
fn is_set_high(&mut self) -> Result<bool, Self::Error>;
173173

174174
/// Is the pin in drive low mode?
175175
///
176176
/// *NOTE* this does *not* read the electrical state of the pin.
177-
fn is_set_low(&self) -> Result<bool, Self::Error>;
177+
fn is_set_low(&mut self) -> Result<bool, Self::Error>;
178178
}
179179

180180
impl<T: StatefulOutputPin + ?Sized> StatefulOutputPin for &mut T {
181181
#[inline]
182-
fn is_set_high(&self) -> Result<bool, Self::Error> {
182+
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
183183
T::is_set_high(self)
184184
}
185185

186186
#[inline]
187-
fn is_set_low(&self) -> Result<bool, Self::Error> {
187+
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
188188
T::is_set_low(self)
189189
}
190190
}
@@ -205,20 +205,20 @@ impl<T: ToggleableOutputPin + ?Sized> ToggleableOutputPin for &mut T {
205205
/// Single digital input pin.
206206
pub trait InputPin: ErrorType {
207207
/// Is the input pin high?
208-
fn is_high(&self) -> Result<bool, Self::Error>;
208+
fn is_high(&mut self) -> Result<bool, Self::Error>;
209209

210210
/// Is the input pin low?
211-
fn is_low(&self) -> Result<bool, Self::Error>;
211+
fn is_low(&mut self) -> Result<bool, Self::Error>;
212212
}
213213

214-
impl<T: InputPin + ?Sized> InputPin for &T {
214+
impl<T: InputPin + ?Sized> InputPin for &mut T {
215215
#[inline]
216-
fn is_high(&self) -> Result<bool, Self::Error> {
216+
fn is_high(&mut self) -> Result<bool, Self::Error> {
217217
T::is_high(self)
218218
}
219219

220220
#[inline]
221-
fn is_low(&self) -> Result<bool, Self::Error> {
221+
fn is_low(&mut self) -> Result<bool, Self::Error> {
222222
T::is_low(self)
223223
}
224224
}

0 commit comments

Comments
 (0)