alamb opened a new issue, #10686:
URL: https://github.com/apache/arrow-rs/issues/10686

   **Is your feature request related to a problem or challenge?**
   - Found while testing upgrade of arrow in DataFusion: 
https://github.com/apache/datafusion/pull/24366
   - Related to https://github.com/apache/arrow-rs/pull/10075
   
   While updating DataFusion to arrow 60 I found that a very common pattern for 
attaching metadata to a `Field` or `Schema` no longer compiles. Before, 
`with_metadata` took a `HashMap<String, String>`, so an array literal converted 
via type inference:
   
   ```rust
   Field::new("name", DataType::Utf8, false)
       .with_metadata([("some_key".to_string(), 
"some_value".to_string())].into())
   ```
   
   Now that metadata parameters are generic (`impl Into<Metadata>`), the 
`.into()` target can no longer be inferred and this fails with `error[E0283]: 
type annotations needed`. The same applies to `Default::default()` and 
`.collect()` in metadata argument position. This was the single largest source 
of churn in the DataFusion upgrade (~25 call sites).
   
   **Describe the solution you'd like**
   
   An array conversion such as:
   
   ```rust
   impl<K: Into<String>, V: Into<String>, const N: usize> From<[(K, V); N]> for 
Metadata
   ```
   
   so callers can pass the array directly, with no `.into()` and no owned 
`String` conversions:
   
   ```rust
   Field::new("name", DataType::Utf8, false).with_metadata([("some_key", 
"some_value")])
   ```
   
   **Describe alternatives you've considered**
   
   Spelling out the type at each call site, e.g. 
`Metadata::new().with("some_key", "some_value")` or `HashMap::from([...])`; 
this works but required touching every call site.
   
   **Additional context**
   


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