datapythonista commented on issue #2696:
URL: https://github.com/apache/arrow-rs/issues/2696#issuecomment-1242825873
I had a look, and the code you shared works great for integer, but for a
string array seems it fails:
```rust
vec!["foo", "bar", "foobar"].iter().collect::<StringArray>()
```
```
Compiling arrow-cookbook v0.1.0 (/home/mgarcia/src/arrow-cookbook)
error[E0277]: a value of type `GenericStringArray<i32>` cannot be built from
an iterator over elements of type `&str`
--> src/create_arrays.rs:90:46
|
90 | vec!["foo", "bar", "foobar"].into_iter().collect::<StringArray>()
| ^^^^^^^ value of type
`GenericStringArray<i32>` cannot be built from `std::iter::Iterator<Item=&str>`
|
= help: the trait `FromIterator<&str>` is not implemented for
`GenericStringArray<i32>`
= help: the following other types implement trait `FromIterator<A>`:
<GenericStringArray<OffsetSize> as FromIterator<&'a
Option<Ptr>>>
<GenericStringArray<OffsetSize> as FromIterator<Option<Ptr>>>
note: required by a bound in `collect`
-->
/home/mgarcia/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1788:19
|
1788 | fn collect<B: FromIterator<Self::Item>>(self) -> B
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in
`collect`
For more information about this error, try `rustc --explain E0277`.
error: could not compile `arrow-cookbook` due to previous error
shell returned 101
```
Is this expected? Is there another syntax for this, or it just doesn't work
for `StringArray`?
Thank you!
```
--
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]