try_len method#723
Conversation
|
Reading this, I remembered the
So maybe the documentation of And to have a similar signatures to other functions in then |
Fixed in 952d8c4. If a length is needed for unsafe operations I believe one is supposed to bound by https://doc.rust-lang.org/std/iter/trait.TrustedLen.html |
|
Hi there. I see this might be handy in some circumstances.
|
Sure. I suppose it would save a re-computation if its useful in the error case.
Either you meant
I chose this name to mirror the naming as in ExactSizeIterator and here. The primary use case is for getting the length from chaining/adapting two iterators known to not overflow a
Sure.
Good catch. Originally it was needed because it incorrectly took |
|
thank you.
I meant to literally eliminate size_hint::try_len by doing the computation directly in Itertools::try_len. As it stands, it only creates an indirection without real need. Regarding ‘[inline]‘: you’re right, there’s no clear pattern in the code base, so let’s just not use it here. |
fixed in 068de35 |
|
Thanks. bors r+ |
|
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page.
|
Add method to get the length of an iterator if the
size_hintis consistent.Reasons why this would be useful:
it.try_len().unwrap()than with the match statement.ExactSizeIteras indicated here. This could be used in those cases.