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


   I tried a blanket implementation like
   
   ```rust
   /// Anything that can be retrieved as &dyn Array is also an Array
   impl<T> Array for T
   where T: AsRef<dyn Array> + fmt::Debug + Send + Sync + JsonEqual
   {
       fn as_any(&self) -> &dyn Any {
           self.as_ref().as_any()
       }
   
       fn data(&self) -> &ArrayData {
           self.as_ref().data()
       }
   }
   
   /// Anything that can be retrieved as &dyn Array is also an Array
   impl<T> JsonEqual for T
   where T: AsRef<dyn JsonEqual>
   {
       fn equals_json(&self, json: &[&serde_json::Value]) -> bool {
           self.as_ref().equals_json(json)
       }
   }
   ```
   
   But that resulted in an error like
   
   ```
   -*- mode: compilation; default-directory: "~/Software/arrow-rs/" -*-
   Compilation started at Sun Jan  2 10:20:57
   
   cd /Users/alamb/Software/arrow-rs && RUST_BACKTRACE=1 
CARGO_TARGET_DIR=/Users/alamb/Software/df-target cargo test -p arrow 
      Compiling arrow v7.0.0-SNAPSHOT (/Users/alamb/Software/arrow-rs/arrow)
   error[E0277]: the trait bound `std::sync::Arc<(dyn array::array::Array + 
'static)>: AsRef<(dyn equal_json::JsonEqual + 'static)>` is not satisfied
      --> arrow/src/array/array.rs:884:34
       |
   884 |         assert!(compute_my_thing(&arr));
       |                 ---------------- ^^^^ the trait `AsRef<(dyn 
equal_json::JsonEqual + 'static)>` is not implemented for `std::sync::Arc<(dyn 
array::array::Array + 'static)>`
       |                 |
       |                 required by a bound introduced by this call
       |
       = help: the following implementations were found:
                 <std::sync::Arc<T> as AsRef<T>>
   note: required because of the requirements on the impl of 
`equal_json::JsonEqual` for `std::sync::Arc<(dyn array::array::Array + 
'static)>`
      --> arrow/src/array/array.rs:241:9
       |
   241 | impl<T> JsonEqual for T
       |         ^^^^^^^^^     ^
   note: required because of the requirements on the impl of 
`array::array::Array` for `std::sync::Arc<(dyn array::array::Array + 'static)>`
      --> arrow/src/array/array.rs:228:9
       |
   228 | impl<T> Array for T
       |         ^^^^^     ^
       = note: required for the cast to the object type `dyn 
array::array::Array`
   
   error[E0308]: mismatched types
      --> arrow/src/array/array.rs:887:34
       |
   887 |         assert!(compute_my_thing(arr));
       |                                  ^^^ expected reference, found struct 
`std::sync::Arc`
       |
       = note: expected reference `&dyn array::array::Array`
                     found struct `std::sync::Arc<(dyn array::array::Array + 
'static)>`
   
   Some errors have detailed explanations: E0277, E0308.
   For more information about an error, try `rustc --explain E0277`.
   error: could not compile `arrow` due to 2 previous errors
   warning: build failed, waiting for other jobs to finish...
   error: build failed
   ```


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