Skip to content

Commit db18718

Browse files
committed
Simplify Debug for {EnumSet, VecDeque}
1 parent 5ca60d9 commit db18718

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

src/libcollections/enum_set.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,7 @@ impl<E> Clone for EnumSet<E> {
4949
#[stable(feature = "rust1", since = "1.0.0")]
5050
impl<E:CLike + fmt::Debug> fmt::Debug for EnumSet<E> {
5151
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
52-
try!(write!(fmt, "{{"));
53-
let mut first = true;
54-
for e in self {
55-
if !first {
56-
try!(write!(fmt, ", "));
57-
}
58-
try!(write!(fmt, "{:?}", e));
59-
first = false;
60-
}
61-
write!(fmt, "}}")
52+
fmt.debug_set().entries(self).finish()
6253
}
6354
}
6455

src/libcollections/vec_deque.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,14 +1787,7 @@ impl<'a, T: 'a + Copy> Extend<&'a T> for VecDeque<T> {
17871787
#[stable(feature = "rust1", since = "1.0.0")]
17881788
impl<T: fmt::Debug> fmt::Debug for VecDeque<T> {
17891789
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1790-
try!(write!(f, "["));
1791-
1792-
for (i, e) in self.iter().enumerate() {
1793-
if i != 0 { try!(write!(f, ", ")); }
1794-
try!(write!(f, "{:?}", *e));
1795-
}
1796-
1797-
write!(f, "]")
1790+
f.debug_list().entries(self).finish()
17981791
}
17991792
}
18001793

0 commit comments

Comments
 (0)