Skip to content

Commit

Permalink
Allow JSON object values to be built from referenced key strings
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Dec 12, 2024
1 parent d3d5888 commit dfacdcd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions firmware/src/json/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ impl From<Vec<Value>> for Value {
}
}

impl<const N: usize> From<[(&str, Value); N]> for Value {
fn from(value: [(&str, Value); N]) -> Self {
Self::Object(value.map(|(k, v)| (k.into(), v)).into())
}
}

impl<const N: usize> From<[(String, Value); N]> for Value {
fn from(value: [(String, Value); N]) -> Self {
Self::Object(value.into())
Expand Down

0 comments on commit dfacdcd

Please sign in to comment.