alamb commented on issue #996:
URL: https://github.com/apache/arrow-rs/issues/996#issuecomment-986042173


   I reviewed the code a bit more, and the comments make a great point:
   
   ```
       /// `ArrowNativeType` is public so that it can be used as a trait bound 
for other public
       /// components, such as the `ToByteSlice` trait.  However, this means 
that it can be
       /// implemented by user defined types, which it is not intended for.
   ```
   
   Meaning that if a user implements `ArrowNativeType` for their types, this 
will result in undefined behavior. 
   
   I also looked more carefully at Buffer and it effectively allows 
reinterpreting arbitrary `bytes` as different types, so I am not sure that 
behavior is safe...
   
   What probably should be done is make `MutableBuffer::typed_data` unsafe 
instead as the docs there say very specifically 
   
   ```
       /// # Safety
       /// This function must only be used when this buffer was extended with 
items of type `T`.
       /// Failure to do so results in undefined behavior.
   ```


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