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

Commit

Permalink
Add debug_assert statement for extend_trusted_len_unzip
Browse files Browse the repository at this point in the history
  • Loading branch information
VasanthakumarV committed Sep 30, 2021
1 parent 5d06bf0 commit cf1adcb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/array/boolean/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ pub(crate) unsafe fn extend_trusted_len_unzip<I, P>(
let (_, upper) = iterator.size_hint();
let additional = upper.expect("extend_trusted_len_unzip requires an upper limit");

// Length of the array before new values are pushed,
// variable created for assertion post operation
let pre_length = values.len();

validity.reserve(additional);
values.reserve(additional);

Expand All @@ -348,6 +352,12 @@ pub(crate) unsafe fn extend_trusted_len_unzip<I, P>(
};
values.push_unchecked(item);
}

debug_assert_eq!(
values.len(),
pre_length + additional,
"Trusted iterator length was not accurately reported"
);
}

/// # Safety
Expand Down

0 comments on commit cf1adcb

Please sign in to comment.