-
Notifications
You must be signed in to change notification settings - Fork 38
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
Document invariant on Ranges #277
Conversation
version-ranges/src/lib.rs
Outdated
/// | ||
/// These ensure that equivalent instances have an identical representation, which is important | ||
/// for `Eq` and `Hash`. Given that this type doesn't know the lower bound, upper bound, granularity | ||
/// or actual instances of `V`, this applies only to equality under pubgrub's model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this applies only to equality under pubgrub's model.
Is there a word missing here? I'm not sure what this was trying to say.
@mpizenberg is our resident wordsmith, so I will leave it up to him. |
Another way to describe: "list of non-overlapping, non-consecutive, intervals with strictly increasing values". The described invariants are good to me. I don’t understand what the last sentence means though. Could you elaborate?
|
Though maybe rule number 1: the sorting doesn’t make much sense until rule 2 and 3 are given. Once we have rules 2 and 3, we know that interval bounds can be sorted. So maybe it should be the last invariant? |
Oh maybe I get it.
Do you mean that the provided invariants cannot guaranty that sets described by these invariants are actually equal if and only if their representation is equal. This is not an equivalence, just an implication. Because for example, In the set of natural numbers, both these sets representations are the valid under the above rule, yet they are different representation of the same:
|
That’s why originally, we forced the rule that left bound is inclusive, and right bound is exclusive, and the set of values must have a strict ordering and every "next" value must be known. Which is annoying when you don’t really know what "next" can be. |
What do you think of replacing the last sentence with something like: Remark: This representation cannot strictly guaranty equality of |
I added an example too so it's more accessible for non-math-background people. |
Ranges keeps up certain invariants internally, we document which they are and why they exist. Currently, they can only be observed by iterating over segments.
Split out from #273.