Skip to content

Commit

Permalink
macro style
Browse files Browse the repository at this point in the history
  • Loading branch information
enricozb committed Apr 11, 2024
1 parent cf1f252 commit 4def02a
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/ops/word.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,39 @@ pub trait ToWord {
macro_rules! impl_signed {
( $($ty:ty),+ ) => {
$(
impl FromWord for $ty {
#[inline(always)]
fn from_word(bits: u64) -> Self {
unsafe { std::mem::transmute::<_, i64>(bits) as Self }
impl FromWord for $ty {
#[inline(always)]
fn from_word(bits: u64) -> Self {
unsafe { std::mem::transmute::<_, i64>(bits) as Self }
}
}
}

impl ToWord for $ty {
#[inline(always)]
fn to_word(self) -> u64 {
unsafe { std::mem::transmute(self as i64) }
impl ToWord for $ty {
#[inline(always)]
fn to_word(self) -> u64 {
unsafe { std::mem::transmute(self as i64) }
}
}
}
)*
};
}

macro_rules! impl_unsigned {
( $($ty:ty),+ ) => {
$(
impl FromWord for $ty {
#[inline(always)]
fn from_word(bits: u64) -> Self {
bits as $ty
impl FromWord for $ty {
#[inline(always)]
fn from_word(bits: u64) -> Self {
bits as Self
}
}
}

impl ToWord for $ty {
#[inline(always)]
fn to_word(self) -> u64 {
self as u64
impl ToWord for $ty {
#[inline(always)]
fn to_word(self) -> u64 {
self as u64
}
}
}
)*
};
}
Expand Down

0 comments on commit 4def02a

Please sign in to comment.