Skip to content

Commit

Permalink
Doctest for PrimitiveArray using from_iter_values. (#694) (#700)
Browse files Browse the repository at this point in the history
* Doctest for PrimitiveArray using from_iter_values.

* Better example for building a PrimitiveArray.

Co-authored-by: Navin <[email protected]>
  • Loading branch information
alamb and novemberkilo authored Aug 20, 2021
1 parent 1fb6210 commit 412a5bd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions arrow/src/array/array_primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 412a5bd

Please sign in to comment.