-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Improve doc of some methods that take ranges #140983
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
base: master
Are you sure you want to change the base?
Conversation
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
@rustbot label +A-docs |
r? @hkBst |
Failed to set assignee to
|
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.
I'm happy with this.
/// Panics if the range has `start_bound > end_bound`, or, a range bound is | ||
/// bounded and greater than the length of the deque. |
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.
I'm not sure about the start_bound
and end_bound
variables here because they aren't parameters. I also find "a range bound" confusing and wasn't sure what it was referring to at first. I would prefer something like this.
/// Panics if the range has `start_bound > end_bound`, or, a range bound is | |
/// bounded and greater than the length of the deque. | |
/// Panics if the starting bound is greater than the end bound, or if any of the range | |
/// bounds are greater than the length of the deque. |
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.
The salient part is that an unbounded range bound is fine, but a bounded one must be in-bounds.
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.
- I think that people understand
start_bound > end_bound
becauseR: RangeBounds<usize>
,RangeBounds
which has those 2 methods. (start_bound
&end_bound
) - Improve doc of some methods that take ranges #140983 (comment). Also, a range can have a
Bound
which is unbounded (which is fine, as pointed by @hkBst.), so I think that this new definition is less precise,
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.
I think that's fine, an unbounded range wouldn't be considered "a range bound greater than the length of the deque". If you feel being more precise is needed then something like "if the range is bounded on either end past the length of the deque" would work, but I find the current wording confusing.
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.
@tkr-sh |
This comment has been minimized.
This comment has been minimized.
Please no emojis in commit messages |
hello @alex-semenyuk ! @rustbot review |
Requested reviewer is already assigned to this pull request. Please choose another assignee. |
@tgross35 is there a guideline in the rustc dev book that says to not do that ? If not, I don't see any reason why I should not do it. |
Some methods that were taking some range in parameter were a bit inconsistent / unclear in the panic documentation.
Here is the recap:
RangeBounds
naming (it's also easier to understand I think)String
methods weren't mentionning that the method panics ifstart_bound > end_bound
but it actually does! It usesslice::range
which panics whenstart > end
. (https://doc.rust-lang.org/stable/src/alloc/string.rs.html#1932-1934, https://doc.rust-lang.org/stable/src/core/slice/index.rs.html#835-837).You can also test it with: