add from bool for use ansi coloring

This commit is contained in:
Tim 'Piepmatz' Hesse 2024-12-23 15:53:04 +01:00
parent f32828625e
commit 146ffe49d0

View file

@ -45,13 +45,19 @@ impl UseAnsiColoring {
}
}
impl From<bool> for UseAnsiColoring {
fn from(value: bool) -> Self {
match value {
true => Self::True,
false => Self::False,
}
}
}
impl FromValue for UseAnsiColoring {
fn from_value(v: Value) -> Result<Self, ShellError> {
if let Ok(v) = v.as_bool() {
return Ok(match v {
true => Self::True,
false => Self::False,
});
return Ok(v.into());
}
#[derive(FromValue)]