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


##########
arrow-array/src/array/boolean_array.rs:
##########
@@ -286,9 +286,7 @@ impl BooleanArray {
     }
 }
 
-impl super::private::Sealed for BooleanArray {}
-
-impl Array for BooleanArray {
+unsafe impl Array for BooleanArray {

Review Comment:
   I think we should annotate these with some sort of generic `// Safetey` 
comments for completeness
   
   Something like
   
   ```rust
   /// SAFETY: Correctly implements the contract of Arrow Arrays
   ```



##########
arrow-array/src/array/mod.rs:
##########
@@ -78,18 +78,16 @@ pub use list_view_array::*;
 
 use crate::iterator::ArrayIter;
 
-mod private {
-    /// Private marker trait to ensure [`super::Array`] can not be implemented 
outside this crate
-    pub trait Sealed {}
-
-    impl<T: Sealed> Sealed for &T {}
-}
-
 /// An array in the [arrow columnar 
format](https://arrow.apache.org/docs/format/Columnar.html)
 ///
-/// This trait is sealed as it is not intended for custom array types, rather 
only
-/// those defined in this crate.
-pub trait Array: std::fmt::Debug + Send + Sync + private::Sealed {
+/// # Safety
+///
+/// Implementations of this trait must ensure that all methods implementations 
comply with
+/// the Arrow specification. No safety guards are placed and failing to comply 
with it can
+/// translate into panics or undefined behavior.
+///
+/// Use it at your own risk knowing that this trait might be sealed in the 
future.

Review Comment:
   This looks good -- the only other thing I can come up with would be to also 
give a specific example
   
   Something like
   ```rust
   /// No safety guards are placed and failing to comply with it can
   /// translate into panics or undefined behavior. For example, 
   /// a value computed based on `len` may be used as a direct index
   /// into memory regions without checks. 
   ```



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