Fix decimal and no_std builds.

This commit is contained in:
Stephen Chung
2021-03-03 13:34:29 +08:00
parent 77277ebf37
commit 58df3ca141
3 changed files with 14 additions and 9 deletions

View File

@@ -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,