From 402c85ca65ae00a01f90989a765d0734ae47edfe Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 25 Aug 2020 09:41:52 +0800 Subject: [PATCH] Fix no_std build. --- src/fn_call.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/fn_call.rs b/src/fn_call.rs index 5186aa0c..f22b89bc 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -52,6 +52,10 @@ use crate::stdlib::{ #[cfg(not(feature = "no_function"))] use crate::stdlib::{collections::HashSet, string::String}; +#[cfg(feature = "no_std")] +#[cfg(not(feature = "no_float"))] +use num_traits::float::Float; + /// Extract the property name from a getter function name. #[inline(always)] fn extract_prop_from_getter(_fn_name: &str) -> Option<&str> { @@ -1147,8 +1151,8 @@ pub fn run_builtin_binary_op( "/" => return Ok(Some((x / y).into())), "%" => return Ok(Some((x % y).into())), "~" => return Ok(Some(x.pow(y as u32).into())), - ">>" => return shr_u(x, y).map(Into::into).map(Some), - "<<" => return shl_u(x, y).map(Into::into).map(Some), + ">>" => return Ok(Some((x >> y).into())), + "<<" => return Ok(Some((x << y).into())), _ => (), } } @@ -1274,9 +1278,9 @@ pub fn run_builtin_op_assignment( "*=" => return Ok(Some(*x *= y)), "/=" => return Ok(Some(*x /= y)), "%=" => return Ok(Some(*x %= y)), - "~=" => return Ok(Some(*x = (*x).pow(y as u32))), - ">>=" => return Ok(Some(*x = shr_u(*x, y)?)), - "<<=" => return Ok(Some(*x = shl_u(*x, y)?)), + "~=" => return Ok(Some(*x = x.pow(y as u32))), + ">>=" => return Ok(Some(*x = *x >> y)), + "<<=" => return Ok(Some(*x = *x << y)), _ => (), } } @@ -1317,7 +1321,7 @@ pub fn run_builtin_op_assignment( "*=" => return Ok(Some(*x *= y)), "/=" => return Ok(Some(*x /= y)), "%=" => return Ok(Some(*x %= y)), - "~=" => return Ok(Some(*x = (*x).powf(y))), + "~=" => return Ok(Some(*x = x.powf(y))), _ => (), } }