Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
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>...
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()); ...
results in:
`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
Implementing Length and TryClone for Cursor<Vec<u8>> would allow for:
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(); ...
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
Attachments
Issue Links
- links to