Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arrow-array/src/array/byte_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ impl<T: ByteArrayType> From<GenericByteArray<T>> for ArrayData {
}
}

/// This does the into_iter() for &'a GenericByteArray
impl<'a, T: ByteArrayType> IntoIterator for &'a GenericByteArray<T> {
type Item = Option<&'a T::Native>;
type IntoIter = ArrayIter<Self>;
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/array/byte_view_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ impl<'a, T: ByteViewType + ?Sized> ArrayAccessor for &'a GenericByteViewArray<T>
}
}

/// This does the into_iter() for &'a GenericByteViewArray
impl<'a, T: ByteViewType + ?Sized> IntoIterator for &'a GenericByteViewArray<T> {
type Item = Option<&'a T::Native>;
type IntoIter = ArrayIter<Self>;
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/array/fixed_size_binary_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ impl<'a> ArrayAccessor for &'a FixedSizeBinaryArray {
}
}

/// This does the into_iter() for &'a FixedSizeBinaryArray
impl<'a> IntoIterator for &'a FixedSizeBinaryArray {
type Item = Option<&'a [u8]>;
type IntoIter = FixedSizeBinaryIter<'a>;
Expand Down
25 changes: 25 additions & 0 deletions arrow-array/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,4 +1248,29 @@ mod tests {
let expected: Int32Array = vec![1, 2, 3].into_iter().map(Some).collect();
assert_eq!(array, expected);
}

use crate::builder::{BinaryViewBuilder, FixedSizeBinaryBuilder};
use crate::ArrayAccessor;

fn use_binary_array<'a>(array: impl ArrayAccessor<Item = &'a [u8]>) {
// Have to manually iterate over the array
for i in 0..array.len() {
dbg!(String::from_utf8(array.value(i).to_vec()).unwrap());
}
}

#[test]
fn binary_array() {
let mut builder = BinaryViewBuilder::new();
builder.append_value(b"foo");
builder.append_value(b"bar");
builder.append_value(b"baz");
use_binary_array(&builder.finish());

let mut builder = FixedSizeBinaryBuilder::new(3);
builder.append_value(b"foo").unwrap();
builder.append_value(b"bar").unwrap();
builder.append_value(b"baz").unwrap();
use_binary_array(&builder.finish());
}
}
Loading