From 90028a6d0dbfa844b69eafbb37c15044ae553429 Mon Sep 17 00:00:00 2001 From: YISH Date: Wed, 20 Feb 2019 03:44:39 +0800 Subject: [PATCH] impl Ieee64::from(f64) and Ieee32::from(f32) --- cranelift/codegen/src/ir/immediates.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cranelift/codegen/src/ir/immediates.rs b/cranelift/codegen/src/ir/immediates.rs index 21d8376e37..36cc470aef 100644 --- a/cranelift/codegen/src/ir/immediates.rs +++ b/cranelift/codegen/src/ir/immediates.rs @@ -665,6 +665,12 @@ impl FromStr for Ieee32 { } } +impl From for Ieee32 { + fn from(x: f32) -> Self { + Ieee32::with_float(x) + } +} + impl Ieee64 { /// Create a new `Ieee64` containing the bits of `x`. pub fn with_bits(x: u64) -> Self { @@ -726,6 +732,12 @@ impl FromStr for Ieee64 { } } +impl From for Ieee64 { + fn from(x: f64) -> Self { + Ieee64::with_float(x) + } +} + #[cfg(test)] mod tests { use super::*;