From 08da407cf3cf2011be59100ea3f615d048bef5ab Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Fri, 15 Jul 2022 19:43:52 -0400 Subject: [PATCH] Allow FieldValue to be created from a slice. --- trustfall_core/src/ir/value.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/trustfall_core/src/ir/value.rs b/trustfall_core/src/ir/value.rs index 790636f3..51b3c2e0 100644 --- a/trustfall_core/src/ir/value.rs +++ b/trustfall_core/src/ir/value.rs @@ -299,8 +299,14 @@ impl> From> for FieldValue { } impl> From> for FieldValue { - fn from(mut v: Vec) -> FieldValue { - FieldValue::List(v.drain(..).map(|x| x.into()).collect()) + fn from(v: Vec) -> FieldValue { + FieldValue::List(v.into_iter().map(|x| x.into()).collect()) + } +} + +impl> From<&[T]> for FieldValue { + fn from(v: &[T]) -> FieldValue { + FieldValue::List(v.iter().map(|x| x.clone().into()).collect()) } }