Skip to content

Commit

Permalink
add 'ZipValidity::unwrap_*' (jorgecarleitao#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Nov 6, 2022
1 parent d02e3a9 commit 8f35c13
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/bitmap/utils/zip_validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,25 @@ where
V: TrustedLen<Item = bool>,
{
}

impl<T, I, V> ZipValidity<T, I, V>
where
I: Iterator<Item = T>,
V: Iterator<Item = bool>,
{
/// Unwrap into an iterator that has no null values.
pub fn unwrap_required(self) -> I {
match self {
ZipValidity::Required(i) => i,
_ => panic!("Could not 'unwrap_required'. 'ZipValidity' iterator has nulls."),
}
}

/// Unwrap into an iterator that has null values.
pub fn unwrap_optional(self) -> ZipValidityIter<T, I, V> {
match self {
ZipValidity::Optional(i) => i,
_ => panic!("Could not 'unwrap_optional'. 'ZipValidity' iterator has no nulls."),
}
}
}

0 comments on commit 8f35c13

Please sign in to comment.