From 3f48740c06cba38af68d279ebb2e12c4e4c21784 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 2 Apr 2020 11:55:54 +0200 Subject: [PATCH] feat(interface-types) Implement `From<&Vec>` for `RecordType`. --- src/interpreter/wasm/values.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/interpreter/wasm/values.rs b/src/interpreter/wasm/values.rs index 472be98..3895aa0 100644 --- a/src/interpreter/wasm/values.rs +++ b/src/interpreter/wasm/values.rs @@ -69,9 +69,7 @@ impl From<&InterfaceValue> for InterfaceType { //InterfaceValue::Anyref(_) => Self::Anyref, InterfaceValue::I32(_) => Self::I32, InterfaceValue::I64(_) => Self::I64, - InterfaceValue::Record(values) => Self::Record(RecordType { - fields: values.iter().map(Into::into).collect(), - }), + InterfaceValue::Record(values) => Self::Record(values.into()), } } } @@ -82,6 +80,14 @@ impl Default for InterfaceValue { } } +impl From<&Vec> for RecordType { + fn from(values: &Vec) -> Self { + RecordType { + fields: values.iter().map(Into::into).collect(), + } + } +} + /// Represents a native type supported by WIT. pub trait NativeType { /// The associated interface type that maps to the native type.