diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index a6f817a89624c..7008411d0f812 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1713,6 +1713,15 @@ pub struct IntoIter { end: *const T, } +#[stable(feature = "vec_intoiter_debug", since = "")] +impl fmt::Debug for IntoIter { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_tuple("IntoIter") + .field(&self.as_slice()) + .finish() + } +} + impl IntoIter { /// Returns the remaining items of this iterator as a slice. /// diff --git a/src/libcollectionstest/vec.rs b/src/libcollectionstest/vec.rs index 9556174bd2294..86f4bbd3c4d38 100644 --- a/src/libcollectionstest/vec.rs +++ b/src/libcollectionstest/vec.rs @@ -501,6 +501,14 @@ fn test_into_iter_as_mut_slice() { assert_eq!(into_iter.as_slice(), &['y', 'c']); } +#[test] +fn test_into_iter_debug() { + let vec = vec!['a', 'b', 'c']; + let into_iter = vec.into_iter(); + let debug = format!("{:?}", into_iter); + assert_eq!(debug, "IntoIter(['a', 'b', 'c'])"); +} + #[test] fn test_into_iter_count() { assert_eq!(vec![1, 2, 3].into_iter().count(), 3);