scovich opened a new issue, #8794: URL: https://github.com/apache/arrow-rs/issues/8794
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.** arrow-rs makes heavy use of `ArrayRef` (= `Arc<dyn Array>`), and it's impossible to impl Array for !Any types because [Array::as_any](https://docs.rs/arrow/latest/arrow/array/trait.Array.html#tymethod.as_any) is a required method. But for some reason we have `Array: Send + Sync` instead of `Array: Any + Send + Sync`, so there's no way to [Arc::downcast](https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.downcast) an `ArrayRef` to e.g. `Arc<StructArray>`. **Describe the solution you'd like** ```rust trait Array: std::any::Any + ... { ... } ``` Which allows ```rust let array: ArrayRef = ...; let struct_array: Arc<StructArray> = Arc::downcast(array).map_err(...)?; ``` One big problem tho -- the blanket `impl<T: Array> Array for &T` means `Array` cannot require `Any` (because `Any: 'static`). I'm not sure how to work around that. **Describe alternatives you've considered** As far as I can tell, with today's code you have to downcast to `&StructArray`, clone it, and allocate a new Arc: ```rust let array: ArrayRef = ...; let struct_array = array.as_struct_opt().ok_or_else(...)?; let struct_array = Arc::new(struct_array.clone()); ``` Sure, cloning an array is _probably_ fairly inexpensive, but there's no way it's as cheap as an arc clone. -- 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]
