alamb commented on code in PR #4379:
URL: https://github.com/apache/arrow-rs/pull/4379#discussion_r1221886496


##########
arrow-array/src/array/primitive_array.rs:
##########
@@ -36,77 +36,157 @@ use std::sync::Arc;
 
 /// An array of `i8`
 ///
-/// # Example: Using `collect`
+/// # Examples
+///
+/// Construction
+///
 /// ```
 /// # use arrow_array::Int8Array;
-/// let arr : Int8Array = [Some(1), Some(2)].into_iter().collect();
+/// // Create from Vec<Option<i8>>

Review Comment:
   This very repetitive example is used for the entire PR but I think shows the 
common ways to create arrays



##########
arrow-buffer/src/bigint.rs:
##########
@@ -97,6 +97,30 @@ impl FromStr for i256 {
     }
 }
 
+impl From<i8> for i256 {

Review Comment:
   Without this to construct an `i256` you need to explicity call 
`i256::from_i128` -- I can remove that and update the examples if that is 
preferable



##########
arrow-array/src/array/boolean_array.rs:
##########
@@ -27,42 +27,50 @@ use std::sync::Arc;
 
 /// An array of [boolean 
values](https://arrow.apache.org/docs/format/Columnar.html#fixed-size-primitive-layout)
 ///
-/// # Example
+/// # Examples
+///
+/// Construction
+///
+/// ```
+///#     use arrow_array::{Array, BooleanArray};
+/// // Create from Vec<Option<bool>>
+/// let arr = BooleanArray::from(vec![Some(false), Some(true), None, 
Some(true)]);
+/// // Create from Vec<bool>
+/// let arr = BooleanArray::from(vec![false, true, true]);
+/// // Create from iter/collect
+/// let arr: BooleanArray = std::iter::repeat(true).take(10).collect();
+/// ```
+///
+/// Construction and Access
 ///
 /// ```
-///     use arrow_array::{Array, BooleanArray};
-///     let arr = BooleanArray::from(vec![Some(false), Some(true), None, 
Some(true)]);
-///     assert_eq!(4, arr.len());
-///     assert_eq!(1, arr.null_count());
-///     assert!(arr.is_valid(0));
-///     assert!(!arr.is_null(0));
-///     assert_eq!(false, arr.value(0));
-///     assert!(arr.is_valid(1));
-///     assert!(!arr.is_null(1));
-///     assert_eq!(true, arr.value(1));
-///     assert!(!arr.is_valid(2));
-///     assert!(arr.is_null(2));
-///     assert!(arr.is_valid(3));
-///     assert!(!arr.is_null(3));
-///     assert_eq!(true, arr.value(3));
+/// use arrow_array::{Array, BooleanArray};
+/// let arr = BooleanArray::from(vec![Some(false), Some(true), None, 
Some(true)]);
+/// assert_eq!(4, arr.len());

Review Comment:
   verifying all the values in the doc example seems overkill so I slimmed it 
down some to keep it concise but also still show the API



-- 
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]

Reply via email to