You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/03/01 04:02:11 UTC

[GitHub] [arrow-rs] viirya commented on pull request #1367: More idiomatic primitive array creation

viirya commented on pull request #1367:
URL: https://github.com/apache/arrow-rs/pull/1367#issuecomment-1054982569


   > Today if people `impl Borrow<i8> for MyAwesomeType` then I think (untested) they can create arrays from an iterator of `MyAwesomeType` which they might not be able to do after this PR 🤔 Though perhaps they just need to implement `ArrowPrimitiveTypeNative`
   
   I guess you mean `impl Borrow<Option<i8>> for MyAwesomeType`? Yes, this is a concern. People need to implement `impl From<MyAwesomeType> for ArrowPrimitiveTypeNative<Int8Type>`.
   
   
   > I tried a little to figure out a clever way to implement the conversion using a trait that is a superset of `Borrow` to make it backwards compatible and more general. Thus instead of
   > 
   > ```rust
   > impl<T: ArrowPrimitiveType, Ptr: Borrow<Option<<T as ArrowPrimitiveType>::Native>>>
   >     FromIterator<Ptr> for PrimitiveArray<T>
   > ```
   > 
   > It would look something like
   > 
   > ```rust
   > impl<T: ArrowPrimitiveType, Ptr: BorrowAsOption<<T as ArrowPrimitiveType>::Native>>
   >     FromIterator<Ptr> for PrimitiveArray<T>
   > ..
   > 
   > pub trait BorrowAsOption<T: ArrowPrimitiveType> {
   >     fn as_native(&self) -> Option<&<T as ArrowPrimitiveType>::Native>;
   > }
   > ```
   > 
   > But my mind was being blown by type errors.
   
   Not sure if I understand above way. Seems people still need to implement `BorrowAsOption`, so it's still not backwards compatible.
   
   


-- 
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-unsubscribe@arrow.apache.org

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