1 use crate::reflect::runtime_types::RuntimeTypeTrait; 2 use crate::reflect::ProtobufValue; 3 use crate::reflect::ReflectValueBox; 4 5 pub(crate) struct ReflectRepeatedDrainIter<'a> { 6 imp: Box<dyn Iterator<Item = ReflectValueBox> + 'a>, 7 } 8 9 impl<'a> ReflectRepeatedDrainIter<'a> { new( imp: impl Iterator<Item = ReflectValueBox> + 'a, ) -> ReflectRepeatedDrainIter<'a>10 pub(crate) fn new( 11 imp: impl Iterator<Item = ReflectValueBox> + 'a, 12 ) -> ReflectRepeatedDrainIter<'a> { 13 ReflectRepeatedDrainIter { imp: Box::new(imp) } 14 } 15 new_vec<V: ProtobufValue>(v: &'a mut Vec<V>) -> ReflectRepeatedDrainIter<'a>16 pub(crate) fn new_vec<V: ProtobufValue>(v: &'a mut Vec<V>) -> ReflectRepeatedDrainIter<'a> { 17 ReflectRepeatedDrainIter::new(v.drain(..).map(V::RuntimeType::into_value_box)) 18 } 19 } 20 21 impl<'a> Iterator for ReflectRepeatedDrainIter<'a> { 22 type Item = ReflectValueBox; 23 next(&mut self) -> Option<Self::Item>24 fn next(&mut self) -> Option<Self::Item> { 25 self.imp.next() 26 } 27 } 28