Skip to content

Instantly share code, notes, and snippets.

@Yoplitein
Created March 8, 2026 09:07
Show Gist options
  • Select an option

  • Save Yoplitein/700666977dda686df2884c5acd480459 to your computer and use it in GitHub Desktop.

Select an option

Save Yoplitein/700666977dda686df2884c5acd480459 to your computer and use it in GitHub Desktop.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum SignalState {
#[default]
Off,
Rising,
Falling,
On,
}
impl From<(bool, bool)> for SignalState {
fn from((previous, current): (bool, bool)) -> Self {
match (previous, current) {
(false, false) => SignalState::Off,
(false, true) => SignalState::Rising,
(true, false) => SignalState::Falling,
(true, true) => SignalState::On,
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment