diff --git a/vortex-array/src/array/bool/mod.rs b/vortex-array/src/array/bool/mod.rs index 157d5762ad..876a0d9a79 100644 --- a/vortex-array/src/array/bool/mod.rs +++ b/vortex-array/src/array/bool/mod.rs @@ -170,13 +170,8 @@ impl FromIterator> for BoolArray { let mut validity: Vec = Vec::with_capacity(lower); let values: Vec = iter .map(|i| { - if let Some(v) = i { - validity.push(true); - v - } else { - validity.push(false); - false - } + validity.push(i.is_some()); + i.unwrap_or_default() }) .collect::>(); diff --git a/vortex-array/src/array/primitive/mod.rs b/vortex-array/src/array/primitive/mod.rs index 5d61d36e5a..02ee95700e 100644 --- a/vortex-array/src/array/primitive/mod.rs +++ b/vortex-array/src/array/primitive/mod.rs @@ -261,13 +261,8 @@ impl FromIterator> for PrimitiveArray { let mut validity: Vec = Vec::with_capacity(lower); let values: Vec = iter .map(|i| { - if let Some(v) = i { - validity.push(true); - v - } else { - validity.push(false); - T::default() - } + validity.push(i.is_some()); + i.unwrap_or_default() }) .collect::>(); @@ -295,10 +290,11 @@ impl ArrayDisplay for PrimitiveArray { #[cfg(test)] mod test { + use crate::array::primitive::PrimitiveArray; + use crate::array::Array; use crate::compute::scalar_at::scalar_at; - use vortex_schema::{IntWidth, Nullability, Signedness}; - - use super::*; + use crate::ptype::PType; + use vortex_schema::{DType, IntWidth, Nullability, Signedness}; #[test] fn from_arrow() {