diff --git a/rust/repeated.rs b/rust/repeated.rs index 5d455922f6..4044b8c67e 100644 --- a/rust/repeated.rs +++ b/rust/repeated.rs @@ -261,6 +261,19 @@ where } } +impl<'msg, T, I, U> IntoProxied> for I +where + I: Iterator, + T: 'msg + ProxiedInRepeated, + U: IntoProxied, +{ + fn into_proxied(self, _private: Private) -> Repeated { + let mut repeated: Repeated = Repeated::new(); + repeated.as_mut().extend(self); + repeated + } +} + /// Types that can appear in a `Repeated`. /// /// This trait is implemented by generated code to communicate how the proxied @@ -588,4 +601,10 @@ mod tests { assert_that!(r.as_mut(), elements_are![eq(0), eq(1), eq(2), eq(3)]); } + + #[test] + fn test_repeated_iter_into_proxied() { + let r: Repeated = [0, 1, 2, 3].into_iter().into_proxied(Private); + assert_that!(r.as_view(), elements_are![eq(0), eq(1), eq(2), eq(3)]); + } }