From 23ef00ba6c233b17e8466e36a7d2bf22967c268a Mon Sep 17 00:00:00 2001 From: meskill <8974488+meskill@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:31:24 +0000 Subject: [PATCH] feat: add FromIterator impl for ObjectAsVec --- src/object_vec.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/object_vec.rs b/src/object_vec.rs index b2e5de0..e0ef6d3 100644 --- a/src/object_vec.rs +++ b/src/object_vec.rs @@ -27,7 +27,13 @@ pub struct ObjectAsVec<'ctx>(pub(crate) Vec<(KeyStrType<'ctx>, Value<'ctx>)>); impl<'ctx> From)>> for ObjectAsVec<'ctx> { fn from(vec: Vec<(&'ctx str, Value<'ctx>)>) -> Self { - Self(vec.into_iter().map(|(k, v)| (k.into(), v)).collect()) + Self::from_iter(vec) + } +} + +impl<'ctx> FromIterator<(&'ctx str, Value<'ctx>)> for ObjectAsVec<'ctx> { + fn from_iter)>>(iter: T) -> Self { + Self(iter.into_iter().map(|(k, v)| (k.into(), v)).collect()) } } @@ -207,6 +213,8 @@ impl<'ctx> From<&ObjectAsVec<'ctx>> for serde_json::Map