From 94b37d558e269290509fc70daff702711f59d521 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:25:06 +1000 Subject: [PATCH 1/2] Add IntoIterator for &Vec<> --- soroban-sdk/src/vec.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/soroban-sdk/src/vec.rs b/soroban-sdk/src/vec.rs index 70ed89b47..f7520ecaa 100644 --- a/soroban-sdk/src/vec.rs +++ b/soroban-sdk/src/vec.rs @@ -894,6 +894,18 @@ where } } +impl IntoIterator for &Vec +where + T: IntoVal + TryFromVal, +{ + type Item = T; + type IntoIter = UnwrappedIter, T, T::Error>; + + fn into_iter(self) -> Self::IntoIter { + self.to_owned().into_iter() + } +} + impl Vec where T: IntoVal + TryFromVal, From e6c3cf7e08c07566ca450843ea72ec018d8ea8bb Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Mon, 9 Sep 2024 22:13:51 +1000 Subject: [PATCH 2/2] fix --- soroban-sdk/src/vec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soroban-sdk/src/vec.rs b/soroban-sdk/src/vec.rs index f7520ecaa..46f66bc9b 100644 --- a/soroban-sdk/src/vec.rs +++ b/soroban-sdk/src/vec.rs @@ -902,7 +902,7 @@ where type IntoIter = UnwrappedIter, T, T::Error>; fn into_iter(self) -> Self::IntoIter { - self.to_owned().into_iter() + self.clone().into_iter() } }