fix(settings): accept numeric environment booleans

This commit is contained in:
Nils Andreas Svee committed 2026-10-14 11:12:33 +07:00
1 parent 4029ce763d
commit 030ceff88f
1 file changed
+23 -1
+23 -1
View File
@@ -47,7 +47,7 @@ where
type Value = bool; type Value = bool;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 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<E>(self, value: bool) -> Result<Self::Value, E> fn visit_bool<E>(self, value: bool) -> Result<Self::Value, E>
@@ -57,6 +57,28 @@ where
Ok(value) Ok(value)
} }
fn visit_i64<E>(self, value: i64) -> Result<Self::Value, E>
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<E>(self, value: u64) -> Result<Self::Value, E>
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<E>(self, value: &str) -> Result<Self::Value, E> fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
where where
E: de::Error, E: de::Error,