Skip to content

Commit 169443f

Browse files
bors[bot]ZoeyR
andauthored
Merge #364
364: Add From impl for pins r=jonas-schievink a=ZoeyR I ran into this when needing to take a generic struct that could contain any gpio pin. Since all the gpio pins have a degrade function I see no reason to not implement `From`. This allows generic code to work better. Co-authored-by: Zoey Riordan <[email protected]>
2 parents f4212d9 + 9b2a07d commit 169443f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

nrf-hal-common/src/gpio.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,12 @@ macro_rules! gpio {
541541
}
542542
}
543543

544+
impl<MODE> From<$PXi<MODE>> for Pin<MODE> {
545+
fn from(value: $PXi<MODE>) -> Self {
546+
value.degrade()
547+
}
548+
}
549+
544550
impl<MODE> OutputPin for $PXi<Output<MODE>> {
545551
type Error = Void;
546552

0 commit comments

Comments
 (0)