Add iterator versions of BTreeSet operations #556
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The motivation for this is when using
union
,intersection
,difference
, andsymmetric_difference
the items have to be cloned, this avoids that and can return borrowed items. What I was shooting for was as if the signature toBTreeSet::intersection
wasThe code is taken from the std lib and altered to work with iterators so it should be sound, still working out a few kinks but nothing major.
I did try implementing the above signature in the std lib but was unable (could be just me) so I tried this out and got it working! Let me know if this is helpful as part of
itertools
.Thanks by the way for a great crate!
Huge problem
This relies on the iterator returning items in sorted order, is this an acceptable invariant to only document (is there any way to add a trait to signify that the iterator needs to be sorted?).