You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "findepi (via GitHub)" <gi...@apache.org> on 2025/09/23 12:07:01 UTC

Re: [I] Option to implement `std::convert::AsRef` for `Field`? [arrow-rs]

findepi commented on issue #5819:
URL: https://github.com/apache/arrow-rs/issues/5819#issuecomment-3323728206

   I tried to workaround lack of `AsRef` provided by `Field`.
   Of course, rust won't allow me to just add `impl AsRef<Field> for Field` in downstream project, so I tried to get away with my own trait as a replacement for `AsRef`
   
   ```rust
   // workaround for the fact that Field does not implement AsRef<Field>
   trait AsFieldRef {
       fn as_ref(&self) -> &Field;
   }
   
   impl AsFieldRef for Field {
       fn as_ref(&self) -> &Field {
           self
       }
   }
   
   impl<T> AsFieldRef for T
   where
       T: AsRef<Field>,
   {
       fn as_ref(&self) -> &Field {
           self.as_ref()
       }
   }
   ```
   
   Unfortunately, this won't work either. Rust reports duplicate implementation because upstream may add `impl AsRef<Field> for Field` in the future.
   


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