replace some transmutes

This commit is contained in:
Aaron Kutch
2020-12-01 23:09:57 -06:00
parent cb4e9755b8
commit 26681724f3
2 changed files with 7 additions and 10 deletions

View File

@@ -1,4 +1,3 @@
use core::mem;
use core::ops;
use super::int::Int;
@@ -85,8 +84,6 @@ pub trait Float:
fn is_subnormal(&self) -> bool;
}
// FIXME: Some of this can be removed if RFC Issue #1424 is resolved
// https://github.com/rust-lang/rfcs/issues/1424
macro_rules! float_impl {
($ty:ident, $ity:ident, $sity:ident, $bits:expr, $significand_bits:expr) => {
impl Float for $ty {
@@ -104,10 +101,10 @@ macro_rules! float_impl {
const EXPONENT_MASK: Self::Int = !(Self::SIGN_MASK | Self::SIGNIFICAND_MASK);
fn repr(self) -> Self::Int {
unsafe { mem::transmute(self) }
self.to_bits()
}
fn signed_repr(self) -> Self::SignedInt {
unsafe { mem::transmute(self) }
self.to_bits() as Self::SignedInt
}
fn eq_repr(self, rhs: Self) -> bool {
if self.is_nan() && rhs.is_nan() {
@@ -117,7 +114,7 @@ macro_rules! float_impl {
}
}
fn from_repr(a: Self::Int) -> Self {
unsafe { mem::transmute(a) }
Self::from_bits(a)
}
fn from_parts(sign: bool, exponent: Self::Int, significand: Self::Int) -> Self {
Self::from_repr(