Skip to content
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

Implement AsRef<[T]> for std::slice::Iter. #35559

Merged
merged 2 commits into from
Aug 17, 2016

Conversation

frewsxcv
Copy link
Member

@frewsxcv frewsxcv commented Aug 10, 2016

AsRef is designed for conversions that are "cheap" (as per
the API docs). It is the case that retrieving the underlying
data of std::slice::Iter is cheap. In my opinion, there's no
ambiguity about what slice data will be returned, otherwise,
I would be more cautious about implementing AsRef.

@@ -996,6 +997,13 @@ impl<'a, T> Clone for Iter<'a, T> {
fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } }
}

#[stable(feature = "rust1", since = "1.12.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have to make up a new feature name for this, even if it's stable.

@alexcrichton alexcrichton added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Aug 10, 2016
@alexcrichton alexcrichton self-assigned this Aug 10, 2016
@alexcrichton
Copy link
Member

Thanks for the PR @frewsxcv! Could you also expand on the motivation for this as well?

`AsRef` is designed for conversions that are "cheap" (as per
the API docs). It is the case that retrieving the underlying
data of `std::slice::Iter` is cheap. In my opinion, there's no
ambiguity about what slice data will be returned, otherwise,
I would be more cautious about implementing `AsRef`.
@frewsxcv
Copy link
Member Author

Thanks for the PR @frewsxcv! Could you also expand on the motivation for this as well?

Updated.

@alexcrichton
Copy link
Member

Thanks! This libs team discussed this PR during triage yesterday and the decision was to merge.

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 16, 2016

📌 Commit dc22186 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Aug 17, 2016

⌛ Testing commit dc22186 with merge 9376da6...

bors added a commit that referenced this pull request Aug 17, 2016
Implement `AsRef<[T]>` for `std::slice::Iter`.

`AsRef` is designed for conversions that are "cheap" (as per
the API docs). It is the case that retrieving the underlying
data of `std::slice::Iter` is cheap. In my opinion, there's no
ambiguity about what slice data will be returned, otherwise,
I would be more cautious about implementing `AsRef`.
@bors bors merged commit dc22186 into rust-lang:master Aug 17, 2016
@frewsxcv frewsxcv deleted the slice-iter-as-ref branch October 2, 2016 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants