Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Toggle enum #354

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading