scovich opened a new pull request, #9295:
URL: https://github.com/apache/arrow-rs/pull/9295

   # Which issue does this PR close?
   
   - Closes https://github.com/apache/arrow-rs/issues/8794
   
   # Rationale for this change
   
   Two things:
   1. An `&ArrayRef` can coerce to `&dyn Array`, but there is currently no way 
to recover the original `ArrayRef` instance afterward, because 
`Array::as_any()` returns the referent of the `ArrayRef`.
   2. An `Arc<T: Array>` can coerce to `ArrayRef`, but there is currently no 
way to recover the orignal `Arc<T>` because `Array` does not (and indeed 
cannot) satisfy the `Any + 'static` bound that `Arc::downcast` requires.
   
   # What changes are included in this PR?
   
   Define a new `Array::as_array_ref()` method, with a provided implementation 
that returns None. `<Arc<T> as Array>::as_array_ref()` returns `Some(self)` and 
`<&T as Array>::as_array_ref()` delegates to its referent.
   
   Define a new freestanding `downcast_array_ref` function that attempts to 
recover the original `Arc<T>` from an owned `ArrayRef` -- mirroring the 
behavior of `Arc::downcast` without the restrictive type bounds.
   
   # Are these changes tested?
   
   Yes, new doc tests validate the code.
   
   # Are there any user-facing changes?
   
   New user-facing functions described above.


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