mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-21 20:15:21 +00:00
vmm: config: Make toggle parsing more tolerant
Support "true" and "false" as well as well as capitalised forms. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
a4e0ce58c7
commit
f449486b9b
@ -250,10 +250,12 @@ impl FromStr for Toggle {
|
||||
type Err = ToggleParseError;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
match s {
|
||||
match s.to_lowercase().as_str() {
|
||||
"" => Ok(Toggle(false)),
|
||||
"on" => Ok(Toggle(true)),
|
||||
"off" => Ok(Toggle(false)),
|
||||
"true" => Ok(Toggle(true)),
|
||||
"false" => Ok(Toggle(false)),
|
||||
_ => Err(ToggleParseError::InvalidValue(s.to_owned())),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user