-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Improve prose around as_slice
example of IterMut
#134619
base: master
Are you sure you want to change the base?
Conversation
@jhpratt want to take this one too? Thanks for reviewing my recent similar changes! |
This comment has been minimized.
This comment has been minimized.
@@ -49,7 +49,7 @@ impl<'a, T> IntoIterator for &'a mut [T] { | |||
/// // First, we need a slice to call the `iter` method on: | |||
/// let slice = &[1, 2, 3]; | |||
/// | |||
/// // Then we call `iter` on the slice to get the `Iter` struct, |
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 is actually correct as-is. Given that it's documentation on the Iter
type itself, there shouldn't be any confusion here. Likewise throughout.
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 is certainly correct, but later prose talks about calling the X method "of the iterator", without an iterator having been mentioned before. If you think it is less clear without struct, perhaps we can use something like "the Iter
struct (which is an iterator)" or "the Iter
struct (which implements the Iterator trait)"? What do you think?
@@ -107,24 +107,20 @@ impl<'a, T> Iter<'a, T> { | |||
|
|||
/// Views the underlying data as a subslice of the original data. | |||
/// | |||
/// This has the same lifetime as the original slice, and so the |
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.
Why remove this?
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.
AFAICT this is just normal borrowing rules and does not seem especially relevant here.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I've removed the cryptic message about not being able to call `&mut self` methods while retaining a shared borrow of the iterator, such as `as_slice` produces. This is just normal borrowing rules and does not seem especially relevant here. I can whip up a replacement if someone thinks it has value.
@rustbot ready |
I've removed the cryptic message about not being able to call
&mut self
methods while retaining a shared borrow of the iterator, such asas_slice
produces. This is just normal borrowing rules and does not seem especially relevant here. I can whip up a replacement if someone thinks it has value.