Fixed zero division and zero assertion errors when [] / 0
This commit is contained in:
parent
947c2552b1
commit
7b5a9aed89
|
@ -760,8 +760,15 @@ impl ops::Div for Value {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Value::Cart(c) => {
|
Value::Cart(c) => {
|
||||||
let cart_len = c.len();
|
let cart_len = match c.len() {
|
||||||
let chunk_len = rhs.into_isize() as usize;
|
0 => return Value::Cart(HashMap::new()),
|
||||||
|
l => l,
|
||||||
|
};
|
||||||
|
|
||||||
|
let chunk_len = match rhs.into_isize() as usize {
|
||||||
|
0 => rand::thread_rng().gen_range(1..=cart_len),
|
||||||
|
l => l,
|
||||||
|
};
|
||||||
|
|
||||||
Value::Cart(
|
Value::Cart(
|
||||||
c.into_iter()
|
c.into_iter()
|
||||||
|
|
Loading…
Reference in a new issue