Skip to content

Commit

Permalink
Assume has_float_to_from_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Feb 8, 2024
1 parent 7212041 commit 4e253cd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
2 changes: 0 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ fn main() {

ac.emit_expression_cfg("1f64.total_cmp(&2f64)", "has_total_cmp"); // 1.62

ac.emit_expression_cfg("3.14f64.to_ne_bytes()", "has_float_to_from_bytes");

autocfg::rerun_path("build.rs");
}
42 changes: 0 additions & 42 deletions src/ops/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ pub trait FromBytes: Sized {

macro_rules! float_to_from_bytes_impl {
($T:ty, $L:expr) => {
#[cfg(has_float_to_from_bytes)]
impl ToBytes for $T {
type Bytes = [u8; $L];

Expand All @@ -170,7 +169,6 @@ macro_rules! float_to_from_bytes_impl {
}
}

#[cfg(has_float_to_from_bytes)]
impl FromBytes for $T {
type Bytes = [u8; $L];

Expand All @@ -189,46 +187,6 @@ macro_rules! float_to_from_bytes_impl {
<$T>::from_ne_bytes(*bytes)
}
}

#[cfg(not(has_float_to_from_bytes))]
impl ToBytes for $T {
type Bytes = [u8; $L];

#[inline]
fn to_be_bytes(&self) -> Self::Bytes {
ToBytes::to_be_bytes(&self.to_bits())
}

#[inline]
fn to_le_bytes(&self) -> Self::Bytes {
ToBytes::to_le_bytes(&self.to_bits())
}

#[inline]
fn to_ne_bytes(&self) -> Self::Bytes {
ToBytes::to_ne_bytes(&self.to_bits())
}
}

#[cfg(not(has_float_to_from_bytes))]
impl FromBytes for $T {
type Bytes = [u8; $L];

#[inline]
fn from_be_bytes(bytes: &Self::Bytes) -> Self {
Self::from_bits(FromBytes::from_be_bytes(bytes))
}

#[inline]
fn from_le_bytes(bytes: &Self::Bytes) -> Self {
Self::from_bits(FromBytes::from_le_bytes(bytes))
}

#[inline]
fn from_ne_bytes(bytes: &Self::Bytes) -> Self {
Self::from_bits(FromBytes::from_ne_bytes(bytes))
}
}
};
}

Expand Down

0 comments on commit 4e253cd

Please sign in to comment.