-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation introduction could be improved #8
Comments
Thanks for the feedback.
|
The new text is an improvement! I would recommend additionally adding a note to the RangeSet.iter doc (currently no doc at all) specifying it iterates over range members and suggesting the |
Added in 7263904 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used RangeSet for a project today. Although it was helpful, I was initially very confused how to use it. Some very important information about RangeSet is actually not in the docs.rs docs but rather is in either the github README or in comments to issues.
I think the following things should be made clear at either https://docs.rs/range-set or https://docs.rs/range-set/0.0.9/range_set/struct.RangeSet.html. If you like, I can submit a PR adding these things to the documentation, but first I would need you to confirm my current understanding of them is correct.
What does the type mean?
The example type of a RangeSet given in the docs is
RangeSet<[RangeInclusive <u32>; 1]>
I could understandRangeSet<u32>
orRangeSet<RangeInclusive<u32>>
, but what is the purpose of the array?I think?: From reading the README I think the idea here is that for a
; N]
array, as an optimization, if the set consists of no more than N elements the elements will be stored entirely within the object ("on the stack") with no additional allocation. Over N it still works, but starts using the heap.Still don't get: Is it legal to use other range types, such as `RangeSet<[Range ]; 1]>?
How do you iterate over ranges, rather than values?
I think?: Per this issue the answer appears to be to say
s.as_ref().iter()
instead ofs.iter()
.What are the purpose of spilled() and shrink_to_fit()?
I think?: These are again about the "on stack" optimization, and they are explained in the smallvec documentation.
Still don't get: Under what circumstances would shrink_to_fit() become relevant? I guess if you add a bunch of ranges forcing a spill and then remove some, the ranges might still be unnecessarily spilled until you shrink()?
Is it possible to immutably query the intersection of two range_sets?
I think?: You can get the intersection using insert_range() or remove_range(), but there is no way to do this without modifying the range_set.
Thanks.
The text was updated successfully, but these errors were encountered: