From 030ceff88f2fb0358f7afbba148088c1cca2cd18 Mon Sep 17 00:00:00 2001 From: Nils Andreas Svee Date: Wed, 14 Oct 2026 11:12:33 +0700 Subject: [PATCH] fix(settings): accept numeric environment booleans --- src/settings/mod.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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,