tustvold commented on code in PR #1819:
URL: https://github.com/apache/arrow-rs/pull/1819#discussion_r892547691


##########
arrow/src/datatypes/native.rs:
##########
@@ -351,8 +382,11 @@ impl JsonSerializable for f64 {
 }
 
 impl ArrowNativeType for f16 {}
+impl private::Sealed for f16 {}
 impl ArrowNativeType for f32 {}
+impl private::Sealed for f32 {}
 impl ArrowNativeType for f64 {}
+impl private::Sealed for f64 {}
 
 /// Allows conversion from supported Arrow types to a byte slice.
 pub trait ToByteSlice {

Review Comment:
   I don't think ToByteSlice assumes transmutability as far as I can tell, 
although the blanket impl for ArrowNativeType is (which is fine)? Am I missing 
something?
   
   ```
   pub trait ToByteSlice {
       /// Converts this instance into a byte slice
       fn to_byte_slice(&self) -> &[u8];
   }
   
   impl<T: ArrowNativeType> ToByteSlice for [T] {
       #[inline]
       fn to_byte_slice(&self) -> &[u8] {
           let raw_ptr = self.as_ptr() as *const T as *const u8;
           unsafe {
               std::slice::from_raw_parts(raw_ptr, self.len() * 
std::mem::size_of::<T>())
           }
       }
   }
   
   impl<T: ArrowNativeType> ToByteSlice for T {
       #[inline]
       fn to_byte_slice(&self) -> &[u8] {
           let raw_ptr = self as *const T as *const u8;
           unsafe { std::slice::from_raw_parts(raw_ptr, 
std::mem::size_of::<T>()) }
       }
   }
   ```



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to