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

Introduce as_slice/as_mut_slice methods on std::vec::IntoIter struct. #35447

Merged
merged 2 commits into from
Aug 15, 2016

Conversation

frewsxcv
Copy link
Member

@frewsxcv frewsxcv commented Aug 7, 2016

Similar to the as_slice method on core::slice::Iter struct.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@apasel422
Copy link
Contributor

This could also have as_slice_mut, no? Would it be better to implement {AsRef, AsMut} instead?

@frewsxcv
Copy link
Member Author

frewsxcv commented Aug 7, 2016

This could also have as_slice_mut, no?

I think so. I can add it in.

Would it be better to implement {AsRef, AsMut} instead?

This works for me too; if anyone has strong opinions on this let me know. core::slice::Iter seems to implement just as_slice. std::vec::Vec seems to implement as_slice and AsRef.

@eddyb
Copy link
Member

eddyb commented Aug 7, 2016

Aren't trait impls insta-stable?

@frewsxcv frewsxcv changed the title Introduce as_slice method on std::vec::IntoIter struct. Introduce as_slice/as_mut_slice methods on std::vec::IntoIter struct. Aug 7, 2016
@alexcrichton alexcrichton added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Aug 8, 2016
@frewsxcv frewsxcv force-pushed the vec-into-iter-as-slice branch 6 times, most recently from 6a7fa66 to ce58686 Compare August 11, 2016 02:57
@alexcrichton
Copy link
Member

@bors: r+

Discussed during libs triage and we were ok, thanks @frewsxcv!

@bors
Copy link
Contributor

bors commented Aug 11, 2016

📌 Commit ce58686 has been approved by alexcrichton

@alexcrichton
Copy link
Member

@bors: r-

Er wait actually, could you open a tracking issue for these methods and update the unstable issue reference?

@frewsxcv
Copy link
Member Author

Er wait actually, could you open a tracking issue for these methods and update the unstable issue reference?

Done.

diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index bce1fca..a6f817a 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -1726,7 +1726,7 @@ impl<T> IntoIter<T> {
     /// let _ = into_iter.next().unwrap();
     /// assert_eq!(into_iter.as_slice(), &['b', 'c']);
     /// ```
-    #[unstable(feature = "vec_into_iter_as_slice", issue = "0")]
+    #[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
     pub fn as_slice(&self) -> &[T] {
         unsafe {
             slice::from_raw_parts(self.ptr, self.len())
@@ -1747,7 +1747,7 @@ impl<T> IntoIter<T> {
     /// assert_eq!(into_iter.next().unwrap(), 'b');
     /// assert_eq!(into_iter.next().unwrap(), 'z');
     /// ```
-    #[unstable(feature = "vec_into_iter_as_slice", issue = "0")]
+    #[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
     pub fn as_mut_slice(&self) -> &mut [T] {
         unsafe {
             slice::from_raw_parts_mut(self.ptr, self.len())

@alexcrichton
Copy link
Member

@bors: r+

Thanks!

@bors
Copy link
Contributor

bors commented Aug 11, 2016

📌 Commit 01a766e has been approved by alexcrichton

Manishearth added a commit to Manishearth/rust that referenced this pull request Aug 13, 2016
…alexcrichton

Introduce `as_slice`/`as_mut_slice` methods on `std::vec::IntoIter` struct.

Similar to the `as_slice` method on `core::slice::Iter` struct.
Manishearth added a commit to Manishearth/rust that referenced this pull request Aug 13, 2016
…alexcrichton

Introduce `as_slice`/`as_mut_slice` methods on `std::vec::IntoIter` struct.

Similar to the `as_slice` method on `core::slice::Iter` struct.
@bors
Copy link
Contributor

bors commented Aug 14, 2016

⌛ Testing commit 01a766e with merge a9a61fb...

@bors
Copy link
Contributor

bors commented Aug 14, 2016

💔 Test failed - auto-linux-64-debug-opt

@alexcrichton
Copy link
Member

@bors: retry

On Sat, Aug 13, 2016 at 8:36 PM, bors [email protected] wrote:

💔 Test failed - auto-linux-64-debug-opt
https://buildbot.rust-lang.org/builders/auto-linux-64-debug-opt/builds/3467


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#35447 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAD95K8FYVgO-vNQUD4NVo99BaVxW8s_ks5qfo1XgaJpZM4JebGs
.

@eddyb
Copy link
Member

eddyb commented Aug 14, 2016

@bors rollup

eddyb added a commit to eddyb/rust that referenced this pull request Aug 14, 2016
…alexcrichton

Introduce `as_slice`/`as_mut_slice` methods on `std::vec::IntoIter` struct.

Similar to the `as_slice` method on `core::slice::Iter` struct.
eddyb added a commit to eddyb/rust that referenced this pull request Aug 14, 2016
…alexcrichton

Introduce `as_slice`/`as_mut_slice` methods on `std::vec::IntoIter` struct.

Similar to the `as_slice` method on `core::slice::Iter` struct.
bors added a commit that referenced this pull request Aug 14, 2016
@bors bors merged commit 01a766e into rust-lang:master Aug 15, 2016
@frewsxcv frewsxcv deleted the vec-into-iter-as-slice branch August 15, 2016 16:34
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Aug 16, 2016
Display all the remaining items of the iterator, similar to the `Debug`
implementation for `core::slice::Iter`:

https://github.com/rust-lang/rust/blob/f0bab98695f0a4877daabad9a5b0ba3e66121392/src/libcore/slice.rs#L930-L937

Using the `as_slice` method that was added in:

rust-lang#35447
@apasel422
Copy link
Contributor

The switch from *const T to *mut T caused vec::IntoIter<T> to go from covariant in T to invariant in T, which is a breaking change. (See contain-rs/vec-map#18.)

I thought we had tests for this.

sophiajt pushed a commit to sophiajt/rust that referenced this pull request Aug 17, 2016
…xcrichton

Implement `Debug` for `std::vec::IntoIter`.

Display all the remaining items of the iterator, similar to the `Debug`
implementation for `core::slice::Iter`:

https://github.com/rust-lang/rust/blob/f0bab98695f0a4877daabad9a5b0ba3e66121392/src/libcore/slice.rs#L930-L937

Using the `as_slice` method that was added in:

rust-lang#35447
sophiajt pushed a commit to sophiajt/rust that referenced this pull request Aug 17, 2016
…xcrichton

Implement `Debug` for `std::vec::IntoIter`.

Display all the remaining items of the iterator, similar to the `Debug`
implementation for `core::slice::Iter`:

https://github.com/rust-lang/rust/blob/f0bab98695f0a4877daabad9a5b0ba3e66121392/src/libcore/slice.rs#L930-L937

Using the `as_slice` method that was added in:

rust-lang#35447
@sfackler
Copy link
Member

sfackler commented Feb 2, 2017

#39465

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.

8 participants