Skip to content

Commit

Permalink
impl From<BufferBuilder<T>> for Buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrobbel committed Dec 11, 2023
1 parent 9630aaf commit 2b382e4
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 2b382e4

Please sign in to comment.