diff options
| author | bors <bors@rust-lang.org> | 2015-03-29 05:21:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-29 05:21:29 +0000 |
| commit | 227b46bdede794d5c8476b810bb1c30926bd9c04 (patch) | |
| tree | 50a0c0dde28dd4deea02c40cf90c713a3075313a /src/libstd | |
| parent | 27af78c6dddc95c7c82dc21926d6ea81562e1211 (diff) | |
| parent | 3c0c8fc43a6dddda37c9e833279e0f8859a05f1c (diff) | |
| download | rust-227b46bdede794d5c8476b810bb1c30926bd9c04.tar.gz rust-227b46bdede794d5c8476b810bb1c30926bd9c04.zip | |
Auto merge of #23810 - sfackler:debug-collections, r=alexcrichton
The collections debug helpers no longer prefix output with the collection name, in line with the current conventions for Debug implementations. Implementations that want to preserve the current behavior can simply add a `try!(write!(fmt, "TypeName "));` at the beginning of the `fmt` method. [breaking-change]
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 9 | ||||
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 9 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 1 |
3 files changed, 3 insertions, 16 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 9e229a28279..276959b715d 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1226,14 +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 { - try!(write!(f, "{{")); - - for (i, (k, v)) in self.iter().enumerate() { - if i != 0 { try!(write!(f, ", ")); } - try!(write!(f, "{:?}: {:?}", *k, *v)); - } - - write!(f, "}}") + self.iter().fold(f.debug_map(), |b, (k, v)| b.entry(k, v)).finish() } } diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 34b905595b7..9a4b55af4d5 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -612,14 +612,7 @@ impl<T, S> fmt::Debug for HashSet<T, S> S: HashState { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(write!(f, "{{")); - - for (i, x) in self.iter().enumerate() { - if i != 0 { try!(write!(f, ", ")); } - try!(write!(f, "{:?}", *x)); - } - - write!(f, "}}") + self.iter().fold(f.debug_set(), |b, e| b.entry(e)).finish() } } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 5f5f2fed567..b7cb8f9ed50 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -128,6 +128,7 @@ #![feature(into_cow)] #![feature(slice_patterns)] #![feature(std_misc)] +#![feature(debug_builders)] #![cfg_attr(test, feature(test, rustc_private, std_misc))] // Don't link to std. We are std. |
