Fold collections debug impls
Also convert [T]'s Debug impl. The behavior of the alternate flag here's changing.
This commit is contained in:
parent
4037f2a368
commit
b82bcec7ce
@ -904,11 +904,7 @@ fn cmp(&self, other: &BTreeMap<K, V>) -> Ordering {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<K: Debug, V: Debug> Debug for BTreeMap<K, V> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut builder = f.debug_map();
|
||||
for (k, v) in self {
|
||||
builder = builder.entry(k, v);
|
||||
}
|
||||
builder.finish()
|
||||
self.iter().fold(f.debug_map(), |b, (k, v)| b.entry(k, v)).finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -628,11 +628,7 @@ fn bitor(self, rhs: &BTreeSet<T>) -> BTreeSet<T> {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: Debug> Debug for BTreeSet<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut builder = f.debug_set();
|
||||
for x in self {
|
||||
builder = builder.entry(x);
|
||||
}
|
||||
builder.finish()
|
||||
self.iter().fold(f.debug_set(), |b, e| b.entry(e)).finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -927,11 +927,7 @@ fn clone(&self) -> LinkedList<A> {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<A: fmt::Debug> fmt::Debug for LinkedList<A> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut builder = f.debug_list();
|
||||
for e in self {
|
||||
builder = builder.entry(e);
|
||||
}
|
||||
builder.finish()
|
||||
self.iter().fold(f.debug_list(), |b, e| b.entry(e)).finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1017,22 +1017,7 @@ fn fmt(&self, f: &mut Formatter) -> Result { f.pad("&Any") }
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: Debug> Debug for [T] {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
if f.flags & (1 << (FlagV1::Alternate as u32)) == 0 {
|
||||
try!(write!(f, "["));
|
||||
}
|
||||
let mut is_first = true;
|
||||
for x in self {
|
||||
if is_first {
|
||||
is_first = false;
|
||||
} else {
|
||||
try!(write!(f, ", "));
|
||||
}
|
||||
try!(write!(f, "{:?}", *x))
|
||||
}
|
||||
if f.flags & (1 << (FlagV1::Alternate as u32)) == 0 {
|
||||
try!(write!(f, "]"));
|
||||
}
|
||||
Ok(())
|
||||
self.iter().fold(f.debug_list(), |b, e| b.entry(e)).finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1226,11 +1226,7 @@ impl<K, V, S> Debug for HashMap<K, V, S>
|
||||
where K: Eq + Hash + Debug, V: Debug, S: HashState
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut builder = f.debug_map();
|
||||
for (k, v) in self.iter() {
|
||||
builder = builder.entry(k, v);
|
||||
}
|
||||
builder.finish()
|
||||
self.iter().fold(f.debug_map(), |b, (k, v)| b.entry(k, v)).finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -614,11 +614,7 @@ impl<T, S> fmt::Debug for HashSet<T, S>
|
||||
S: HashState
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut builder = f.debug_set();
|
||||
for x in self {
|
||||
builder = builder.entry(x);
|
||||
}
|
||||
builder.finish()
|
||||
self.iter().fold(f.debug_set(), |b, e| b.entry(e)).finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user