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 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.

@frewsxcv frewsxcv force-pushed the frewsxcv:slice-iter-as-ref branch from 2cecd9a to 9581999 Aug 10, 2016
@@ -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")]

This comment has been minimized.

Copy link
@apasel422

apasel422 Aug 10, 2016

Member

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

@frewsxcv frewsxcv force-pushed the frewsxcv:slice-iter-as-ref branch from 9581999 to 97ee61d Aug 10, 2016
@alexcrichton alexcrichton added the T-libs label Aug 10, 2016
@alexcrichton alexcrichton self-assigned this Aug 10, 2016
@alexcrichton
Copy link
Member

alexcrichton commented Aug 10, 2016

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

frewsxcv added 2 commits 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`.
@frewsxcv frewsxcv force-pushed the frewsxcv:slice-iter-as-ref branch from 97ee61d to dc22186 Aug 16, 2016
@frewsxcv
Copy link
Member Author

frewsxcv commented Aug 16, 2016

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

Updated.

@alexcrichton
Copy link
Member

alexcrichton commented Aug 16, 2016

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
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@frewsxcv frewsxcv deleted the frewsxcv:slice-iter-as-ref branch Oct 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.