Skip to content

Commit

Permalink
Allow FieldValue to be created from a slice.
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi committed Jul 15, 2022
1 parent 844543d commit 08da407
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions trustfall_core/src/ir/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,14 @@ impl<T: Into<FieldValue>> From<Option<T>> for FieldValue {
}

impl<T: Into<FieldValue>> From<Vec<T>> for FieldValue {
fn from(mut v: Vec<T>) -> FieldValue {
FieldValue::List(v.drain(..).map(|x| x.into()).collect())
fn from(v: Vec<T>) -> FieldValue {
FieldValue::List(v.into_iter().map(|x| x.into()).collect())
}
}

impl<T: Clone + Into<FieldValue>> From<&[T]> for FieldValue {
fn from(v: &[T]) -> FieldValue {
FieldValue::List(v.iter().map(|x| x.clone().into()).collect())
}
}

Expand Down

0 comments on commit 08da407

Please sign in to comment.