Skip to content

Commit

Permalink
Merge pull request #1215 from dtolnay/fromarray
Browse files Browse the repository at this point in the history
Implement From<[T; N]> for Value
  • Loading branch information
dtolnay authored Nov 17, 2024
2 parents 2ccb5b6 + 4e5f985 commit 2b65ca0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/value/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ impl<T: Into<Value>> From<Vec<T>> for Value {
}
}

impl<T: Into<Value>, const N: usize> From<[T; N]> for Value {
fn from(array: [T; N]) -> Self {
Value::Array(array.into_iter().map(Into::into).collect())
}
}

impl<T: Clone + Into<Value>> From<&[T]> for Value {
/// Convert a slice to `Value::Array`.
///
Expand Down

0 comments on commit 2b65ca0

Please sign in to comment.