Fix decimal and no_std builds.
This commit is contained in:
parent
77277ebf37
commit
58df3ca141
@ -1447,9 +1447,9 @@ impl Dynamic {
|
||||
/// Exported under the `decimal` feature only.
|
||||
#[cfg(feature = "decimal")]
|
||||
#[inline(always)]
|
||||
pub fn as_decimal(self) -> Result<Decimal, &'static str> {
|
||||
match self.0 {
|
||||
Union::Decimal(n, _) => Ok(*n),
|
||||
pub fn as_decimal(&self) -> Result<Decimal, &'static str> {
|
||||
match &self.0 {
|
||||
Union::Decimal(n, _) => Ok(**n),
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
Union::Shared(_, _) => self.read_lock().map(|v| *v).ok_or_else(|| self.type_name()),
|
||||
_ => Err(self.type_name()),
|
||||
|
@ -946,27 +946,32 @@ pub fn get_builtin_op_assignment_fn(
|
||||
match op {
|
||||
"+=" => {
|
||||
return Some(|_, args| {
|
||||
Ok((*args[0].write_lock::<Decimal>().unwrap() += get_y(args)).into())
|
||||
let y = get_y(args);
|
||||
Ok((*args[0].write_lock::<Decimal>().unwrap() += y).into())
|
||||
})
|
||||
}
|
||||
"-=" => {
|
||||
return Some(|_, args| {
|
||||
Ok((*args[0].write_lock::<Decimal>().unwrap() -= get_y(args)).into())
|
||||
let y = get_y(args);
|
||||
Ok((*args[0].write_lock::<Decimal>().unwrap() -= y).into())
|
||||
})
|
||||
}
|
||||
"*=" => {
|
||||
return Some(|_, args| {
|
||||
Ok((*args[0].write_lock::<Decimal>().unwrap() *= get_y(args)).into())
|
||||
let y = get_y(args);
|
||||
Ok((*args[0].write_lock::<Decimal>().unwrap() *= y).into())
|
||||
})
|
||||
}
|
||||
"/=" => {
|
||||
return Some(|_, args| {
|
||||
Ok((*args[0].write_lock::<Decimal>().unwrap() /= get_y(args)).into())
|
||||
let y = get_y(args);
|
||||
Ok((*args[0].write_lock::<Decimal>().unwrap() /= y).into())
|
||||
})
|
||||
}
|
||||
"%=" => {
|
||||
return Some(|_, args| {
|
||||
Ok((*args[0].write_lock::<Decimal>().unwrap() %= get_y(args)).into())
|
||||
let y = get_y(args);
|
||||
Ok((*args[0].write_lock::<Decimal>().unwrap() %= y).into())
|
||||
})
|
||||
}
|
||||
_ => return None,
|
||||
|
@ -88,7 +88,7 @@ mod token;
|
||||
mod r#unsafe;
|
||||
mod utils;
|
||||
|
||||
pub type RhaiResult = Result<Dynamic, Box<EvalAltResult>>;
|
||||
pub type RhaiResult = Result<Dynamic, stdlib::boxed::Box<EvalAltResult>>;
|
||||
|
||||
/// The system integer type. It is defined as [`i64`].
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user