Modified Str -> Int coercion

pull/10/head
ondra05 2022-04-26 00:18:11 +02:00
parent 4b7aa07d06
commit b6f37b6ced
1 changed files with 3 additions and 1 deletions

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