Fixed zero division and zero assertion errors when [] / 0

This commit is contained in:
Erin 2022-05-04 23:15:12 +02:00 committed by ondra05
parent 43b00e607a
commit 22e8f63bac

View file

@ -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()