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

Merged
merged 2 commits into from Aug 17, 2016

Conversation

Projects
None yet
4 participants
@frewsxcv
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.

src/libcore/slice.rs
@@ -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.

@apasel422

apasel422 Aug 10, 2016

Member

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

@apasel422

apasel422 Aug 10, 2016

Member

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

@alexcrichton alexcrichton added the T-libs label Aug 10, 2016

@alexcrichton alexcrichton self-assigned this Aug 10, 2016

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Aug 10, 2016

Member

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

Member

alexcrichton commented Aug 10, 2016

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

frewsxcv added some commits Aug 10, 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`.
@frewsxcv

This comment has been minimized.

Show comment
Hide comment
@frewsxcv

frewsxcv Aug 16, 2016

Member

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

Updated.

Member

frewsxcv commented Aug 16, 2016

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

Updated.

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Aug 16, 2016

Member

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

@bors: r+

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

This comment has been minimized.

Show comment
Hide comment
@bors

bors Aug 16, 2016

Contributor

📌 Commit dc22186 has been approved by alexcrichton

Contributor

bors commented Aug 16, 2016

📌 Commit dc22186 has been approved by alexcrichton

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Aug 17, 2016

Contributor

⌛️ Testing commit dc22186 with merge 9376da6...

Contributor

bors commented Aug 17, 2016

⌛️ Testing commit dc22186 with merge 9376da6...

bors added a commit that referenced this pull request Aug 17, 2016

Auto merge of #35559 - frewsxcv:slice-iter-as-ref, r=alexcrichton
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

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