Improved type coercions

pull/6/head
ondra05 2022-03-30 20:56:59 +02:00
parent c867ad8406
commit bdbf8d0a29
1 changed files with 3 additions and 9 deletions

View File

@ -226,16 +226,10 @@ impl Value {
match self {
Value::Nul => Abool::Never,
Value::Str(s) => match s.to_lowercase().as_str() {
"never" => Abool::Never,
"never" | "no" | "🇳🇴" => Abool::Never,
"sometimes" => Abool::Sometimes,
"always" => Abool::Always,
s => {
if s.is_empty() {
Abool::Never
} else {
Abool::Always
}
}
"always" | "yes" => Abool::Always,
s => (!s.is_empty()).into(),
},
Value::Int(x) => match x.cmp(&0) {
std::cmp::Ordering::Less => Abool::Never,