Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
add BooleanArray::from_trusted_len_values_iter_unchecked
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Feb 3, 2022
1 parent 777f375 commit 3ebd4fe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/array/boolean/from.rs
Expand Up @@ -18,6 +18,19 @@ impl BooleanArray {
MutableBooleanArray::from_trusted_len_values_iter(iterator).into()
}

/// Creates a new [`BooleanArray`] from an [`TrustedLen`] of `bool`.
/// Use this over [`BooleanArray::from_trusted_len_iter`] when the iterator is trusted len
/// but this crate does not mark it as such.
/// # Safety
/// The iterator must be [`TrustedLen`](https://doc.rust-lang.org/std/iter/trait.TrustedLen.html).
/// I.e. that `size_hint().1` correctly reports its length.
#[inline]
pub unsafe fn from_trusted_len_values_iter_unchecked<I: Iterator<Item = bool>>(
iterator: I,
) -> Self {
MutableBooleanArray::from_trusted_len_iter_unchecked(iterator).into()
}

/// Creates a new [`BooleanArray`] from a slice of `bool`.
#[inline]
pub fn from_slice<P: AsRef<[bool]>>(slice: P) -> Self {
Expand Down

0 comments on commit 3ebd4fe

Please sign in to comment.