scovich commented on code in PR #8625:
URL: https://github.com/apache/arrow-rs/pull/8625#discussion_r2432819812
##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -439,6 +440,22 @@ impl From<VariantArray> for ArrayRef {
}
}
+impl<'m, 'v> FromIterator<Option<Variant<'m, 'v>>> for VariantArray {
+ fn from_iter<T: IntoIterator<Item = Option<Variant<'m, 'v>>>>(iter: T) ->
Self {
+ let mut b = VariantArrayBuilder::new(0);
+ b.extend(iter);
+ b.build()
+ }
+}
+
+impl<'m, 'v> FromIterator<Variant<'m, 'v>> for VariantArray {
+ fn from_iter<T: IntoIterator<Item = Variant<'m, 'v>>>(iter: T) -> Self {
+ let mut b = VariantArrayBuilder::new(0);
+ b.extend(iter);
+ b.build()
+ }
+}
+
Review Comment:
Most std lib code I've seen relies on the iterator's lower bound
[hint](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.size_hint),
with a fallback path if that turned out to be too low.
There's also the
[ExactSizeIterator](https://doc.rust-lang.org/std/iter/trait.ExactSizeIterator.html)
trait, but given how rust treats potentially overlapping generic definitions
as conflicts, I don't know how to provide implementations for both Iterator and
ExactSizeIterator?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]