You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2025/07/29 10:07:32 UTC
(arrow-rs) branch main updated: [Variant] impl FromIterator for VariantPath (#8011)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 00a2f7354d [Variant] impl FromIterator for VariantPath (#8011)
00a2f7354d is described below
commit 00a2f7354d4aa42ad2ff6c5a3bff3f2ea17ca4ba
Author: Kosta Tarasov <33...@users.noreply.github.com>
AuthorDate: Tue Jul 29 06:07:26 2025 -0400
[Variant] impl FromIterator for VariantPath (#8011)
# Which issue does this PR close?
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax.
- Closes #7955.
# Rationale for this change
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
# What changes are included in this PR?
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
# Are these changes tested?
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
# Are there any user-facing changes?
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.
---------
Co-authored-by: Konstantin.Tarasov <ko...@nyct.com>
---
parquet-variant/src/path.rs | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/parquet-variant/src/path.rs b/parquet-variant/src/path.rs
index 42dbdb3abc..ddbfc5e469 100644
--- a/parquet-variant/src/path.rs
+++ b/parquet-variant/src/path.rs
@@ -43,13 +43,13 @@ use std::{borrow::Cow, ops::Deref};
/// // access the field "foo" and then the first element in a variant list value
/// let path = VariantPath::from("foo").join(0);
/// // this is the same as the previous one
-/// let path2 = VariantPath::new(vec!["foo".into(), 0.into()]);
+/// let path2 = VariantPath::from_iter(["foo".into(), 0.into()]);
/// assert_eq!(path, path2);
/// // you can also create a path from a vector of `VariantPathElement` directly
-/// let path3 = VariantPath::new(vec![
+/// let path3 = [
/// VariantPathElement::field("foo"),
/// VariantPathElement::index(0)
-/// ]);
+/// ].into_iter().collect::<VariantPath>();
/// assert_eq!(path, path3);
/// ```
///
@@ -109,6 +109,13 @@ impl<'a> From<usize> for VariantPath<'a> {
}
}
+/// Create from iter
+impl<'a> FromIterator<VariantPathElement<'a>> for VariantPath<'a> {
+ fn from_iter<T: IntoIterator<Item = VariantPathElement<'a>>>(iter: T) -> Self {
+ VariantPath::new(Vec::from_iter(iter))
+ }
+}
+
impl<'a> Deref for VariantPath<'a> {
type Target = [VariantPathElement<'a>];