Format let-else statements

This commit is contained in:
Max Brunsfeld 2023-08-25 10:11:32 -07:00
parent 732af201dc
commit 404f76739c
28 changed files with 210 additions and 109 deletions

View file

@ -63,20 +63,23 @@ impl KeymapFile {
// string. But `RawValue` currently does not work inside of an untagged enum.
match action {
Value::Array(items) => {
let Ok([name, data]): Result<[serde_json::Value; 2], _> = items.try_into() else {
let Ok([name, data]): Result<[serde_json::Value; 2], _> =
items.try_into()
else {
return Some(Err(anyhow!("Expected array of length 2")));
};
let serde_json::Value::String(name) = name else {
return Some(Err(anyhow!("Expected first item in array to be a string.")))
return Some(Err(anyhow!(
"Expected first item in array to be a string."
)));
};
cx.deserialize_action(
&name,
Some(data),
)
},
cx.deserialize_action(&name, Some(data))
}
Value::String(name) => cx.deserialize_action(&name, None),
Value::Null => Ok(no_action()),
_ => return Some(Err(anyhow!("Expected two-element array, got {action:?}"))),
_ => {
return Some(Err(anyhow!("Expected two-element array, got {action:?}")))
}
}
.with_context(|| {
format!(