Skip to content

Commit

Permalink
Remove Toggle enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh3Rm4n committed Nov 28, 2023
1 parent 22de3d0 commit e89516a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Deprecate `Toggle` enum and use `Switch` instead for better naming purposes
([#334])
- Add `impl From<Toggle> for Switch` to reduce churn.
- Remove `Toggle` enum and use `Switch` instead for better naming purposes
- Fix undefined behavior in SPI implementation ([#346])
- Add `num_traits::PrimInt` bounds to `Word`
- Remove `Serial::split`, which possibly creates two mutable references two
Expand Down
27 changes: 1 addition & 26 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,46 +270,21 @@ cfg_if! {
}
}

/// Toggle something on or off.
///
/// Convenience enum and wrapper around a bool, which more explicit about the intention to enable
/// or disable something, in comparison to `true` or `false`.
// TODO: Maybe move to some mod like "util"?
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[deprecated(since = "0.10.0", note = "Use Switch instead")]
#[allow(deprecated)]
pub enum Toggle {
/// Toggle something on / enable a thing.
On,
/// Toggle something off / disable a thing.
Off,
}

/// Switch something on or off.
///
/// Convenience enum and wrapper around a bool, which more explicit about the intention to enable
/// or disable something, in comparison to `true` or `false`.
// TODO: Maybe move to some mod like "util"?
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[doc(alias = "Toggle")]
pub enum Switch {
/// Switch something on / enable a thing.
On,
/// Switch something off / disable a thing.
Off,
}

#[allow(deprecated)]
impl From<Toggle> for Switch {
fn from(toggle: Toggle) -> Self {
match toggle {
Toggle::On => Switch::On,
Toggle::Off => Switch::Off,
}
}
}

impl From<Switch> for bool {
fn from(switch: Switch) -> Self {
matches!(switch, Switch::On)
Expand Down

0 comments on commit e89516a

Please sign in to comment.