[
https://issues.apache.org/jira/browse/ARROW-7768?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
David Kegley updated ARROW-7768:
--------------------------------
Description:
Currently Length and TryClone are implemented for Cursor<&'a [u8]> in
src/file/reader.rs
Attempting to create a cursor from a Vec<u8>...
{code:java}
fn test_cursor_and_file_has_the_same_behaviour() {
let mut buf: Vec<u8> = Vec::new();
get_test_file("alltypes_plain.parquet")
.read_to_end(&mut buf)
.unwrap();
let cursor = Cursor::new(buf.as_slice());
...
{code}
results in:
{code:java}
`buf` does not live long enough
borrowed value does not live long enough
rustc(E0597)
reader.rs(681, 34): borrowed value does not live long enough
reader.rs(681, 34): argument requires that `buf` is borrowed for `'static`
reader.rs(691, 5): `buf` dropped here while still borrowed
{code}
Implementing Length and TryClone for Cursor<Vec<u8>> would allow for:
{code:java}
fn test_cursor_and_file_has_the_same_behaviour() {
let mut buf: Vec<u8> = Vec::new();
get_test_file("alltypes_plain.parquet")
.read_to_end(&mut buf)
.unwrap();
let cursor = Cursor::new(buf);
let read_from_cursor = SerializedFileReader::new(cursor).unwrap();
...
{code}
Otherwise, buf: Vec<u8> must be declared static in order to initialize a
SerializedFileReader from a Cursor.
I'm new to rust so perhaps this is the intended behavior, but if not I'm happy
to submit a PR for this
was:
Currently Length and TryClone are implemented for Cursor<&'a [u8]> in
src/file/reader.rs
Attempting to create a cursor from a Vec<u8>
{code:java}
fn test_cursor_and_file_has_the_same_behaviour() {
let mut buf: Vec<u8> = Vec::new();
get_test_file("alltypes_plain.parquet")
.read_to_end(&mut buf)
.unwrap();
let cursor = Cursor::new(buf.as_slice());
...
{code}
results in:
{code:java}
`buf` does not live long enough
borrowed value does not live long enoughrustc(E0597)reader.rs(681, 34):
borrowed value does not live long enoughreader.rs(681, 34): argument requires
that `buf` is borrowed for `'static`reader.rs(691, 5): `buf` dropped here while
still borrowed
{code}
Implementing Length and TryClone for Cursor<Vec<u8>> would allow for:
{code:java}
fn test_cursor_and_file_has_the_same_behaviour() {
let mut buf: Vec<u8> = Vec::new();
get_test_file("alltypes_plain.parquet")
.read_to_end(&mut buf)
.unwrap();
let cursor = Cursor::new(buf);
let read_from_cursor = SerializedFileReader::new(cursor).unwrap();
...
{code}
Otherwise, buf: Vec<u8> must be declared static in order to initialize a
SerializedFileReader from a Cursor.
I'm new to rust so perhaps this is the intended behavior, but if not I'm happy
to submit a PR for this
> Implement Length and TryClone traits for Cursor<Vec<u8>> in reader.rs
> ---------------------------------------------------------------------
>
> Key: ARROW-7768
> URL: https://issues.apache.org/jira/browse/ARROW-7768
> Project: Apache Arrow
> Issue Type: Improvement
> Components: Rust
> Reporter: David Kegley
> Priority: Minor
>
> Currently Length and TryClone are implemented for Cursor<&'a [u8]> in
> src/file/reader.rs
> Attempting to create a cursor from a Vec<u8>...
> {code:java}
> fn test_cursor_and_file_has_the_same_behaviour() {
> let mut buf: Vec<u8> = Vec::new();
> get_test_file("alltypes_plain.parquet")
> .read_to_end(&mut buf)
> .unwrap();
> let cursor = Cursor::new(buf.as_slice());
> ...
> {code}
>
> results in:
> {code:java}
> `buf` does not live long enough
> borrowed value does not live long enough
> rustc(E0597)
> reader.rs(681, 34): borrowed value does not live long enough
> reader.rs(681, 34): argument requires that `buf` is borrowed for `'static`
> reader.rs(691, 5): `buf` dropped here while still borrowed
> {code}
>
> Implementing Length and TryClone for Cursor<Vec<u8>> would allow for:
> {code:java}
> fn test_cursor_and_file_has_the_same_behaviour() {
> let mut buf: Vec<u8> = Vec::new();
> get_test_file("alltypes_plain.parquet")
> .read_to_end(&mut buf)
> .unwrap();
> let cursor = Cursor::new(buf);
> let read_from_cursor = SerializedFileReader::new(cursor).unwrap();
> ...
> {code}
> Otherwise, buf: Vec<u8> must be declared static in order to initialize a
> SerializedFileReader from a Cursor.
> I'm new to rust so perhaps this is the intended behavior, but if not I'm
> happy to submit a PR for this
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)