Skip to content

Commit 6b47f89

Browse files
committed
into_state
1 parent 2204203 commit 6b47f89

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/gpio/hal_1.rs

+13-15
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ use embedded_hal_one::digital::blocking::{
1010
};
1111
pub use embedded_hal_one::digital::PinState;
1212

13-
impl From<PinState> for super::PinState {
14-
fn from(state: PinState) -> Self {
15-
match state {
16-
PinState::Low => Self::Low,
17-
PinState::High => Self::High,
18-
}
13+
fn into_state(state: PinState) -> super::PinState {
14+
match state {
15+
PinState::Low => super::PinState::Low,
16+
PinState::High => super::PinState::High,
1917
}
2018
}
2119

@@ -93,7 +91,7 @@ impl<const P: char, const N: u8> IoPin<Self, Self> for Pin<Output<OpenDrain>, P,
9391
Ok(self)
9492
}
9593
fn into_output_pin(mut self, state: PinState) -> Result<Self, Self::Error> {
96-
self.set_state(state.into());
94+
self.set_state(into_state(state));
9795
Ok(self)
9896
}
9997
}
@@ -106,7 +104,7 @@ impl<const P: char, const N: u8> IoPin<Pin<Input<Floating>, P, N>, Self>
106104
Ok(self.into_floating_input())
107105
}
108106
fn into_output_pin(mut self, state: PinState) -> Result<Self, Self::Error> {
109-
self.set_state(state.into());
107+
self.set_state(into_state(state));
110108
Ok(self)
111109
}
112110
}
@@ -119,7 +117,7 @@ impl<const P: char, const N: u8> IoPin<Self, Pin<Output<OpenDrain>, P, N>>
119117
Ok(self)
120118
}
121119
fn into_output_pin(self, state: PinState) -> Result<Pin<Output<OpenDrain>, P, N>, Self::Error> {
122-
Ok(self.into_open_drain_output_in_state(state.into()))
120+
Ok(self.into_open_drain_output_in_state(into_state(state)))
123121
}
124122
}
125123

@@ -131,7 +129,7 @@ impl<const P: char, const N: u8> IoPin<Pin<Input<Floating>, P, N>, Self>
131129
Ok(self.into_floating_input())
132130
}
133131
fn into_output_pin(mut self, state: PinState) -> Result<Self, Self::Error> {
134-
self.set_state(state.into());
132+
self.set_state(into_state(state));
135133
Ok(self)
136134
}
137135
}
@@ -144,7 +142,7 @@ impl<const P: char, const N: u8> IoPin<Self, Pin<Output<PushPull>, P, N>>
144142
Ok(self)
145143
}
146144
fn into_output_pin(self, state: PinState) -> Result<Pin<Output<PushPull>, P, N>, Self::Error> {
147-
Ok(self.into_push_pull_output_in_state(state.into()))
145+
Ok(self.into_push_pull_output_in_state(into_state(state)))
148146
}
149147
}
150148

@@ -156,7 +154,7 @@ impl<const P: char, const N: u8> IoPin<Pin<Input<PullUp>, P, N>, Self>
156154
Ok(self.into_pull_up_input())
157155
}
158156
fn into_output_pin(mut self, state: PinState) -> Result<Self, Self::Error> {
159-
self.set_state(state.into());
157+
self.set_state(into_state(state));
160158
Ok(self)
161159
}
162160
}
@@ -169,7 +167,7 @@ impl<const P: char, const N: u8> IoPin<Self, Pin<Output<PushPull>, P, N>>
169167
Ok(self)
170168
}
171169
fn into_output_pin(self, state: PinState) -> Result<Pin<Output<PushPull>, P, N>, Self::Error> {
172-
Ok(self.into_push_pull_output_in_state(state.into()))
170+
Ok(self.into_push_pull_output_in_state(into_state(state)))
173171
}
174172
}
175173

@@ -181,7 +179,7 @@ impl<const P: char, const N: u8> IoPin<Pin<Input<PullDown>, P, N>, Self>
181179
Ok(self.into_pull_down_input())
182180
}
183181
fn into_output_pin(mut self, state: PinState) -> Result<Self, Self::Error> {
184-
self.set_state(state.into());
182+
self.set_state(into_state(state));
185183
Ok(self)
186184
}
187185
}
@@ -194,7 +192,7 @@ impl<const P: char, const N: u8> IoPin<Self, Pin<Output<PushPull>, P, N>>
194192
Ok(self)
195193
}
196194
fn into_output_pin(self, state: PinState) -> Result<Pin<Output<PushPull>, P, N>, Self::Error> {
197-
Ok(self.into_push_pull_output_in_state(state.into()))
195+
Ok(self.into_push_pull_output_in_state(into_state(state)))
198196
}
199197
}
200198

0 commit comments

Comments
 (0)