emilk opened a new pull request, #10729:
URL: https://github.com/apache/arrow-rs/pull/10729

   # Which issue does this PR close?
   
   * Follow-up to https://github.com/apache/arrow-rs/pull/10656 
(https://github.com/apache/arrow-rs/pull/10656#discussion_r3771712125)
   * Part of https://github.com/apache/arrow-rs/issues/10553
   
   # Rationale for this change
   
   `size_hint` is only a hint: an iterator may report no upper bound at all, 
and is [not 
required](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.size_hint)
 to yield the number of items it reports. `from_iter_values` used the upper 
bound only to pre-allocate, yet panicked when there was none.
   
   # What changes are included in this PR?
   
   `GenericByteArray::from_iter_values` now falls back to the lower bound when 
there is no upper bound, and no longer panics. The `# Panics` doc is updated.
   
   This was the only such case: the remaining `size_hint().1.expect(…)` sites 
are all in `unsafe` trusted-length APIs, where the panic guards a safety 
contract.
   
   # Are these changes tested?
   
   Yes, new test with an iterator that reports no upper bound, and one that 
over-reports.
   
   # Are there any user-facing changes?
   
   One less panic. No breaking changes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to