diff --git a/pgrx/src/datum/array.rs b/pgrx/src/datum/array.rs index 645c5c201..9a27dc7cb 100644 --- a/pgrx/src/datum/array.rs +++ b/pgrx/src/datum/array.rs @@ -424,18 +424,19 @@ impl<'a, T: FromDatum> Iterator for ArrayIntoIterator<'a, T> { } fn size_hint(&self) -> (usize, Option) { - (0, Some(self.array.nelems)) - } - - fn count(self) -> usize - where - Self: Sized, - { - self.array.nelems + // If asking for size, it's not clear if they want "actual size" + // or "size minus nulls"? Let's lower bound on 0 if nulls exist. + let left = self.array.nelems - self.curr; + if let NullKind::Strict(_) = self.array.null_slice { + (left, Some(left)) + } else { + (0, Some(left)) + } } - fn nth(&mut self, n: usize) -> Option { - self.array.get(n) + fn count(self) -> usize { + // TODO: This code is dangerously under-exercised in the test suite. + self.array.nelems - self.curr } }