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

saul: Compatibly rename G* variants #50

Merged
merged 1 commit into from
Feb 24, 2023
Merged
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
28 changes: 19 additions & 9 deletions src/saul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,13 @@ pub enum Unit {
M,
M2,
M3,
G,
GForce,
Dps,
Gr,
Gram,
A,
V,
W,
Gs,
Gauss,
T,
Dbm,
Coulomb,
Expand All @@ -399,6 +399,16 @@ pub enum Unit {
}

impl Unit {
// Note that on the C side the code still uses the aliases on the C side -- they're deprecated,
// but we'd need to introduce a marker, and given they'll stay deprecated on C for a release,
// we can just switch over before they go.
#[deprecated(note = "Use the GForce variant instead")]
const G: Self = Unit::GForce;
#[deprecated(note = "Use the Gram variant instead")]
const Gr: Self = Unit::Gram;
#[deprecated(note = "Use the Gauss variant instead")]
const Gs: Self = Unit::Gauss;

fn from_c(input: u8) -> Option<Self> {
match input as _ {
riot_sys::UNIT_NONE => Some(Unit::None),
Expand All @@ -409,13 +419,13 @@ impl Unit {
riot_sys::UNIT_M => Some(Unit::M),
riot_sys::UNIT_M2 => Some(Unit::M2),
riot_sys::UNIT_M3 => Some(Unit::M3),
riot_sys::UNIT_G => Some(Unit::G),
riot_sys::UNIT_G => Some(Unit::GForce),
riot_sys::UNIT_DPS => Some(Unit::Dps),
riot_sys::UNIT_GR => Some(Unit::Gr),
riot_sys::UNIT_GR => Some(Unit::Gram),
riot_sys::UNIT_A => Some(Unit::A),
riot_sys::UNIT_V => Some(Unit::V),
riot_sys::UNIT_W => Some(Unit::W),
riot_sys::UNIT_GS => Some(Unit::Gs),
riot_sys::UNIT_GS => Some(Unit::Gauss),
riot_sys::UNIT_T => Some(Unit::T),
riot_sys::UNIT_DBM => Some(Unit::Dbm),
riot_sys::UNIT_COULOMB => Some(Unit::Coulomb),
Expand Down Expand Up @@ -449,13 +459,13 @@ impl Unit {
Some(Unit::M) => riot_sys::UNIT_M,
Some(Unit::M2) => riot_sys::UNIT_M2,
Some(Unit::M3) => riot_sys::UNIT_M3,
Some(Unit::G) => riot_sys::UNIT_G,
Some(Unit::GForce) => riot_sys::UNIT_G,
Some(Unit::Dps) => riot_sys::UNIT_DPS,
Some(Unit::Gr) => riot_sys::UNIT_GR,
Some(Unit::Gram) => riot_sys::UNIT_GR,
Some(Unit::A) => riot_sys::UNIT_A,
Some(Unit::V) => riot_sys::UNIT_V,
Some(Unit::W) => riot_sys::UNIT_W,
Some(Unit::Gs) => riot_sys::UNIT_GS,
Some(Unit::Gauss) => riot_sys::UNIT_GS,
Some(Unit::T) => riot_sys::UNIT_T,
Some(Unit::Dbm) => riot_sys::UNIT_DBM,
Some(Unit::Coulomb) => riot_sys::UNIT_COULOMB,
Expand Down