This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch active_release
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/active_release by this push:
     new 412a5bd  Doctest for PrimitiveArray using from_iter_values. (#694) 
(#700)
412a5bd is described below

commit 412a5bde386c29e18d83570ce42fabfc9c207f27
Author: Andrew Lamb <[email protected]>
AuthorDate: Fri Aug 20 09:16:54 2021 -0400

    Doctest for PrimitiveArray using from_iter_values. (#694) (#700)
    
    * Doctest for PrimitiveArray using from_iter_values.
    
    * Better example for building a PrimitiveArray.
    
    Co-authored-by: Navin <[email protected]>
---
 arrow/src/array/array_primitive.rs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arrow/src/array/array_primitive.rs 
b/arrow/src/array/array_primitive.rs
index 9c14f88..5777a03 100644
--- a/arrow/src/array/array_primitive.rs
+++ b/arrow/src/array/array_primitive.rs
@@ -44,6 +44,19 @@ const MICROSECONDS: i64 = 1_000_000;
 const NANOSECONDS: i64 = 1_000_000_000;
 
 /// Array whose elements are of primitive types.
+///
+/// # Example: From an iterator of values
+///
+/// ```
+/// use arrow::array::{Array, PrimitiveArray};
+/// use arrow::datatypes::Int32Type;
+/// let arr: PrimitiveArray<Int32Type> = 
PrimitiveArray::from_iter_values((0..10).map(|x| x + 1));
+/// assert_eq!(10, arr.len());
+/// assert_eq!(0, arr.null_count());
+/// for i in 0..10i32 {
+///     assert_eq!(i + 1, arr.value(i as usize));
+/// }
+/// ```
 pub struct PrimitiveArray<T: ArrowPrimitiveType> {
     /// Underlying ArrayData
     /// # Safety

Reply via email to