Replace PlaceBack Debug implementation with derive

This commit is contained in:
Guillaume Gomez 2017-01-21 00:33:38 +01:00
parent 668af801cf
commit 0cc2448e05
9 changed files with 59 additions and 94 deletions

View File

@ -228,7 +228,7 @@ pub struct PeekMut<'a, T: 'a + Ord> {
sift: bool,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: Ord + fmt::Debug> fmt::Debug for PeekMut<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("PeekMut")
@ -977,10 +977,10 @@ pub struct Iter<'a, T: 'a> {
iter: slice::Iter<'a, T>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("BinaryHeap::Iter")
f.debug_tuple("Iter")
.field(&self.iter.as_slice())
.finish()
}
@ -1034,10 +1034,10 @@ pub struct IntoIter<T> {
iter: vec::IntoIter<T>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<T: fmt::Debug> fmt::Debug for IntoIter<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("BinaryHeap::IntoIter")
f.debug_tuple("IntoIter")
.field(&self.iter.as_slice())
.finish()
}
@ -1078,19 +1078,11 @@ impl<T> FusedIterator for IntoIter<T> {}
/// An iterator that drains a `BinaryHeap`.
#[stable(feature = "drain", since = "1.6.0")]
#[derive(Debug)]
pub struct Drain<'a, T: 'a> {
iter: vec::Drain<'a, T>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Drain<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("BinaryHeap::Drain")
.field(&self.iter)
.finish()
}
}
#[stable(feature = "drain", since = "1.6.0")]
impl<'a, T: 'a> Iterator for Drain<'a, T> {
type Item = T;
@ -1236,11 +1228,13 @@ where T: Clone + Ord {
place: vec::PlaceBack<'a, T>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[unstable(feature = "collection_placement",
reason = "placement protocol is subject to change",
issue = "30172")]
impl<'a, T: Clone + Ord + fmt::Debug> fmt::Debug for BinaryHeapPlace<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("BinaryHeapPlace")
.field(&self)
.field(&self.place)
.finish()
}
}

View File

@ -270,7 +270,7 @@ pub struct Iter<'a, K: 'a, V: 'a> {
length: usize,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Iter<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.clone()).finish()
@ -279,18 +279,12 @@ impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Iter<'a, K, V> {
/// A mutable iterator over a BTreeMap's entries.
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct IterMut<'a, K: 'a, V: 'a> {
range: RangeMut<'a, K, V>,
length: usize,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for IterMut<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad(&format!("BTreeMap::IterMut({:?})", self.range))
}
}
/// An owning iterator over a BTreeMap's entries.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<K, V> {
@ -299,7 +293,7 @@ pub struct IntoIter<K, V> {
length: usize,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for IntoIter<K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let range = Range {
@ -316,7 +310,7 @@ pub struct Keys<'a, K: 'a, V: 'a> {
inner: Iter<'a, K, V>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Keys<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.inner.clone()).finish()
@ -329,7 +323,7 @@ pub struct Values<'a, K: 'a, V: 'a> {
inner: Iter<'a, K, V>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.inner.clone()).finish()
@ -338,24 +332,18 @@ impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V>
/// A mutable iterator over a BTreeMap's values.
#[stable(feature = "map_values_mut", since = "1.10.0")]
#[derive(Debug)]
pub struct ValuesMut<'a, K: 'a, V: 'a> {
inner: IterMut<'a, K, V>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for ValuesMut<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad(&format!("BTreeMap::ValuesMut({:?})", self.inner))
}
}
/// An iterator over a sub-range of BTreeMap's entries.
pub struct Range<'a, K: 'a, V: 'a> {
front: Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Edge>,
back: Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Edge>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Range<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.clone()).finish()
@ -371,7 +359,7 @@ pub struct RangeMut<'a, K: 'a, V: 'a> {
_marker: PhantomData<&'a mut (K, V)>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for RangeMut<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let range = Range {

View File

@ -85,10 +85,10 @@ pub struct Iter<'a, T: 'a> {
iter: Keys<'a, T, ()>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("BTreeSet::Iter")
f.debug_tuple("Iter")
.field(&self.iter.clone())
.finish()
}
@ -101,34 +101,22 @@ impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> {
///
/// [`BTreeSet`]: struct.BTreeSet.html
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct IntoIter<T> {
iter: ::btree_map::IntoIter<T, ()>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
impl<T: fmt::Debug> fmt::Debug for IntoIter<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad(&format!("BTreeSet::IntoIter({:?})", self.iter))
}
}
/// An iterator over a sub-range of `BTreeSet`'s items.
///
/// This structure is created by the [`range`] method on [`BTreeSet`].
///
/// [`BTreeSet`]: struct.BTreeSet.html
/// [`range`]: struct.BTreeSet.html#method.range
#[derive(Debug)]
pub struct Range<'a, T: 'a> {
iter: ::btree_map::Range<'a, T, ()>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Range<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad(&format!("BTreeSet::Range({:?})", self.iter))
}
}
/// A lazy iterator producing elements in the set difference (in-order).
///
/// This structure is created by the [`difference`] method on [`BTreeSet`].
@ -141,10 +129,10 @@ pub struct Difference<'a, T: 'a> {
b: Peekable<Iter<'a, T>>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Difference<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("BTreeSet::Difference")
f.debug_tuple("Difference")
.field(&self.clone())
.finish()
}
@ -163,10 +151,10 @@ pub struct SymmetricDifference<'a, T: 'a> {
b: Peekable<Iter<'a, T>>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for SymmetricDifference<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("BTreeSet::SymmetricDifference")
f.debug_tuple("SymmetricDifference")
.field(&self.clone())
.finish()
}
@ -184,10 +172,10 @@ pub struct Intersection<'a, T: 'a> {
b: Peekable<Iter<'a, T>>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Intersection<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("BTreeSet::Intersection")
f.debug_tuple("Intersection")
.field(&self.clone())
.finish()
}
@ -205,10 +193,10 @@ pub struct Union<'a, T: 'a> {
b: Peekable<Iter<'a, T>>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Union<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("BTreeSet::Union")
f.debug_tuple("Union")
.field(&self.clone())
.finish()
}

View File

@ -220,10 +220,9 @@ pub struct Iter<E> {
marker: marker::PhantomData<E>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
impl<E: fmt::Debug> fmt::Debug for Iter<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("EnumSet::Iter")
f.debug_tuple("Iter")
.field(&self.clone())
.finish()
}

View File

@ -65,10 +65,10 @@ pub struct Iter<'a, T: 'a> {
marker: PhantomData<&'a Node<T>>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("LinkedList::Iter")
f.debug_tuple("Iter")
.field(&self.clone())
.finish()
}
@ -91,10 +91,10 @@ pub struct IterMut<'a, T: 'a> {
len: usize,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("LinkedList::IterMut")
f.debug_tuple("IterMut")
.field(self.clone())
.finish()
}
@ -107,10 +107,10 @@ pub struct IntoIter<T> {
list: LinkedList<T>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<T: fmt::Debug> fmt::Debug for IntoIter<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("LinkedList::IntoIter")
f.debug_tuple("IntoIter")
.field(self.clone())
.finish()
}
@ -1104,10 +1104,12 @@ pub struct FrontPlace<'a, T: 'a> {
node: IntermediateBox<Node<T>>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[unstable(feature = "collection_placement",
reason = "struct name and placement protocol are subject to change",
issue = "30172")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for FrontPlace<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("LinkedList::FrontPlace")
f.debug_tuple("FrontPlace")
.field(self.clone())
.finish()
}
@ -1157,10 +1159,12 @@ pub struct BackPlace<'a, T: 'a> {
node: IntermediateBox<Node<T>>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[unstable(feature = "collection_placement",
reason = "struct name and placement protocol are subject to change",
issue = "30172")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for BackPlace<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("LinkedList::BackPlace")
f.debug_tuple("BackPlace")
.field(self.clone())
.finish()
}

View File

@ -123,7 +123,7 @@ pub struct EncodeUtf16<'a> {
encoder: Utf16Encoder<Chars<'a>>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a> fmt::Debug for EncodeUtf16<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("EncodeUtf16 { .. }")

View File

@ -1979,10 +1979,10 @@ pub struct Drain<'a> {
iter: Chars<'a>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a> fmt::Debug for Drain<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("String::Drain { .. }")
f.pad("Drain { .. }")
}
}

View File

@ -2092,10 +2092,10 @@ pub struct Drain<'a, T: 'a> {
vec: Shared<Vec<T>>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Drain<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Vec::Drain")
f.debug_tuple("Drain")
.field(&self.iter.as_slice())
.finish()
}
@ -2167,19 +2167,11 @@ impl<'a, T> FusedIterator for Drain<'a, T> {}
#[unstable(feature = "collection_placement",
reason = "struct name and placement protocol are subject to change",
issue = "30172")]
#[derive(Debug)]
pub struct PlaceBack<'a, T: 'a> {
vec: &'a mut Vec<T>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for PlaceBack<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Vec::PlaceBack")
.field(&self.vec.as_slice())
.finish()
}
}
#[unstable(feature = "collection_placement",
reason = "placement protocol is subject to change",
issue = "30172")]

View File

@ -1866,10 +1866,10 @@ pub struct Iter<'a, T: 'a> {
head: usize,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("VecDeque::Iter")
f.debug_tuple("Iter")
.field(&self.clone())
.finish()
}
@ -1947,10 +1947,10 @@ pub struct IterMut<'a, T: 'a> {
head: usize,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("VecDeque::IterMut")
f.debug_tuple("IterMut")
.field(&self.clone())
.finish()
}
@ -2022,10 +2022,10 @@ pub struct IntoIter<T> {
inner: VecDeque<T>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<T: fmt::Debug> fmt::Debug for IntoIter<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("VecDeque::IntoIter")
f.debug_tuple("IntoIter")
.field(&self.clone())
.finish()
}
@ -2074,10 +2074,10 @@ pub struct Drain<'a, T: 'a> {
deque: Shared<VecDeque<T>>,
}
#[stable(feature = "collection_debug", since = "1.15.0")]
#[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Drain<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("VecDeque::Drain")
f.debug_tuple("Drain")
.field(&self.clone())
.finish()
}