Modified Str -> Int coercion

This commit is contained in:
Erin 2022-04-26 00:18:11 +02:00 committed by ondra05
parent 85226fbfbb
commit b76e890fb7

View file

@ -213,7 +213,9 @@ impl Value {
}, },
Value::Int(i) => i, Value::Int(i) => i,
Value::Nul => consts::ANSWER, Value::Nul => consts::ANSWER,
Value::Str(text) => text.parse().unwrap_or(consts::ANSWER), Value::Str(text) => text
.parse()
.unwrap_or_else(|_| text.chars().map(|cr| cr as isize).sum()),
Value::Cart(c) => c Value::Cart(c) => c
.into_iter() .into_iter()
.map(|(i, v)| i.into_isize() * v.borrow().clone().into_isize()) .map(|(i, v)| i.into_isize() * v.borrow().clone().into_isize())