diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-02-13 17:31:47 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-13 17:31:47 +0000 |
| commit | e3f8020c3bdf726dfa451b5b190f27191507a18f (patch) | |
| tree | d7cdf1f69ff2ee77b057fc5ede5fad7b3eb46762 | |
| parent | 41a563aae3e474955892b27487e185f5f486f525 (diff) | |
| parent | dfc58ad3a27d9313bebbd0ee49976afb54df772e (diff) | |
Merge #1215
1215: Add clone to embassy_rp::gpio::Level r=Dirbaio a=Slushee-a
Allows you to wite a cleaner state change detector. Example:
```rs
let mut button_state: Level = Level::Low;
let mut prev_button_state: Level = button_state;
loop {
button_state = button.get_level();
if prev_button_state != button_state {
led.set_level(button_state); // Takes ownership of button_state.
}
prev_button_state = button_state; // Can't be done since the ownership has been moved.
// Adding Clone makes this code possible
}
```
Co-authored-by: Slushee <[email protected]>
| -rw-r--r-- | embassy-rp/src/gpio.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index 4abb98394..76d4281ff 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs | |||
| @@ -16,7 +16,7 @@ const NEW_AW: AtomicWaker = AtomicWaker::new(); | |||
| 16 | static INTERRUPT_WAKERS: [AtomicWaker; PIN_COUNT] = [NEW_AW; PIN_COUNT]; | 16 | static INTERRUPT_WAKERS: [AtomicWaker; PIN_COUNT] = [NEW_AW; PIN_COUNT]; |
| 17 | 17 | ||
| 18 | /// Represents a digital input or output level. | 18 | /// Represents a digital input or output level. |
| 19 | #[derive(Debug, Eq, PartialEq)] | 19 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| 20 | pub enum Level { | 20 | pub enum Level { |
| 21 | Low, | 21 | Low, |
| 22 | High, | 22 | High, |
