Explorar o código

Allow conversion of integers to booleans by comparing to 0

Isaac Woods %!s(int64=4) %!d(string=hai) anos
pai
achega
7ee3f5ce99
Modificáronse 1 ficheiros con 1 adicións e 0 borrados
  1. 1 0
      aml/src/value.rs

+ 1 - 0
aml/src/value.rs

@@ -175,6 +175,7 @@ impl AmlValue {
     pub fn as_bool(&self) -> Result<bool, AmlError> {
         match self {
             AmlValue::Boolean(value) => Ok(*value),
+            AmlValue::Integer(value) => Ok(*value != 0),
             _ => Err(AmlError::IncompatibleValueConversion),
         }
     }