diff --git a/src/settings/mod.rs b/src/settings/mod.rs index 6ca0571..f80cf5e 100644 --- a/src/settings/mod.rs +++ b/src/settings/mod.rs @@ -47,7 +47,7 @@ where type Value = bool; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("a boolean or a UCI-compatible boolean string") + formatter.write_str("a boolean, integer 0 or 1, or a UCI-compatible boolean string") } fn visit_bool(self, value: bool) -> Result @@ -57,6 +57,28 @@ where Ok(value) } + fn visit_i64(self, value: i64) -> Result + where + E: de::Error, + { + match value { + 0 => Ok(false), + 1 => Ok(true), + _ => Err(E::custom("boolean integer must be 0 or 1")), + } + } + + fn visit_u64(self, value: u64) -> Result + where + E: de::Error, + { + match value { + 0 => Ok(false), + 1 => Ok(true), + _ => Err(E::custom("boolean integer must be 0 or 1")), + } + } + fn visit_str(self, value: &str) -> Result where E: de::Error,