Modified Str -> Int coercion

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

View file

@ -213,7 +213,9 @@ impl Value {
},
Value::Int(i) => i,
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
.into_iter()
.map(|(i, v)| i.into_isize() * v.borrow().clone().into_isize())