Skip to content

Commit

Permalink
impl From<BufferBuilder<T>> for Buffer (#5202)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrobbel authored Dec 11, 2023
1 parent 1553545 commit 8aa55dd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions arrow-buffer/src/buffer/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::sync::Arc;

use crate::alloc::{Allocation, Deallocation, ALIGNMENT};
use crate::util::bit_chunk_iterator::{BitChunks, UnalignedBitChunk};
use crate::BufferBuilder;
use crate::{bytes::Bytes, native::ArrowNativeType};

use super::ops::bitwise_unary_op_helper;
Expand Down Expand Up @@ -371,6 +372,12 @@ impl From<MutableBuffer> for Buffer {
}
}

impl<T: ArrowNativeType> From<BufferBuilder<T>> for Buffer {
fn from(mut value: BufferBuilder<T>) -> Self {
value.finish()
}
}

impl Buffer {
/// Creates a [`Buffer`] from an [`Iterator`] with a trusted (upper) length.
/// Prefer this to `collect` whenever possible, as it is ~60% faster.
Expand Down

0 comments on commit 8aa55dd

Please sign in to comment.