Skip to content

Commit

Permalink
allow SliceableCursor to be constructed from an Arc directly (#369)
Browse files Browse the repository at this point in the history
This is backwards-compatible since we change the argument from `Vec<u8>`
to `impl Into<Arc<Vec<u8>>>` and the following implementations exists in
std:

- `impl<T, U> Into<U> for T where U: From<T>` (reverse direction)
- `impl<T> From<T> for Arc<T>` (create `Arc` from any type)

Furthermore `Arc<Vec<u8>>` can be passed directly now because the following
implementations exists:

- `impl<T> From<T> for T` (identity)

Closes #368.
  • Loading branch information
crepererum authored May 26, 2021
1 parent 74d5957 commit b802895
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions parquet/src/util/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ impl fmt::Debug for SliceableCursor {
}

impl SliceableCursor {
pub fn new(content: Vec<u8>) -> Self {
let size = content.len();
pub fn new(content: impl Into<Arc<Vec<u8>>>) -> Self {
let inner = content.into();
let size = inner.len();
SliceableCursor {
inner: Arc::new(content),
inner,
start: 0,
pos: 0,
length: size,
Expand Down

0 comments on commit b802895

Please sign in to comment.