Skip to content

Commit

Permalink
Replace transmute<u{32,64}, f{32,64}> with f{32,64}::from_bits
Browse files Browse the repository at this point in the history
  • Loading branch information
KellerFuchs authored and Geal committed Jan 28, 2019
1 parent d6f1bad commit 3c48f82
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/nom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ macro_rules! i128 ( ($i:expr, $e:expr) => ( {if $crate::Endianness::Big == $e {
pub fn be_f32(input: &[u8]) -> IResult<&[u8], f32> {
match be_u32(input) {
Err(e) => Err(e),
Ok((i, o)) => unsafe { Ok((i, transmute::<u32, f32>(o))) },
Ok((i, o)) => Ok((i, f32::from_bits(o))),
}
}

Expand All @@ -712,7 +712,7 @@ pub fn be_f32(input: &[u8]) -> IResult<&[u8], f32> {
pub fn be_f64(input: &[u8]) -> IResult<&[u8], f64> {
match be_u64(input) {
Err(e) => Err(e),
Ok((i, o)) => unsafe { Ok((i, transmute::<u64, f64>(o))) },
Ok((i, o)) => Ok((i, f64::from_bits(o))),
}
}

Expand All @@ -721,7 +721,7 @@ pub fn be_f64(input: &[u8]) -> IResult<&[u8], f64> {
pub fn le_f32(input: &[u8]) -> IResult<&[u8], f32> {
match le_u32(input) {
Err(e) => Err(e),
Ok((i, o)) => unsafe { Ok((i, transmute::<u32, f32>(o))) },
Ok((i, o)) => Ok((i, f32::from_bits(o))),
}
}

Expand All @@ -730,7 +730,7 @@ pub fn le_f32(input: &[u8]) -> IResult<&[u8], f32> {
pub fn le_f64(input: &[u8]) -> IResult<&[u8], f64> {
match le_u64(input) {
Err(e) => Err(e),
Ok((i, o)) => unsafe { Ok((i, transmute::<u64, f64>(o))) },
Ok((i, o)) => Ok((i, f64::from_bits(o))),
}
}

Expand Down

0 comments on commit 3c48f82

Please sign in to comment.