diff options
| author | Samuel Chase <samebchase@gmail.com> | 2013-05-11 19:09:11 +0530 |
|---|---|---|
| committer | Samuel Chase <samebchase@gmail.com> | 2013-05-11 19:09:11 +0530 |
| commit | b8d0ebe124a574a55d9df7daf2b704802443aa2c (patch) | |
| tree | 8ba560556f01eb481f32154fb296a2f37985f81f | |
| parent | 3c1e78788423f6036d370c4ea37718f3494868e7 (diff) | |
| download | rust-b8d0ebe124a574a55d9df7daf2b704802443aa2c.tar.gz rust-b8d0ebe124a574a55d9df7daf2b704802443aa2c.zip | |
Remove extra space between key and value.
1. Extra space removed. 2. Using acc.push_str() instead of str::push_str 3. Update test to reflect representation change.
| -rw-r--r-- | src/libcore/to_str.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index a54bb7e94a2..3806335e240 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -15,7 +15,9 @@ The `ToStr` trait for converting to strings */ use str; +use str::OwnedStr; use hashmap::HashMap; +use hashmap::HashSet; use container::Map; use hash::Hash; use cmp::Eq; @@ -59,13 +61,13 @@ impl<A:ToStr+Hash+Eq, B:ToStr+Hash+Eq> ToStr for HashMap<A, B> { first = false; } else { - str::push_str(&mut acc, ~", "); + acc.push_str(", "); } - str::push_str(&mut acc, key.to_str()); - str::push_str(&mut acc, ~" : "); - str::push_str(&mut acc, value.to_str()); + acc.push_str(key.to_str()); + acc.push_str(": "); + acc.push_str(value.to_str()); } - str::push_char(&mut acc, '}'); + acc.push_char('}'); acc } } @@ -82,6 +84,7 @@ impl<A:ToStr,B:ToStr> ToStr for (A, B) { } } } + impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) { #[inline(always)] fn to_str(&self) -> ~str { @@ -185,7 +188,7 @@ mod tests { let table_str = table.to_str(); - assert!(table_str == ~"{1 : 2, 3 : 4}" || table_str == ~"{3 : 4, 1 : 2}"); + assert!(table_str == ~"{1: 2, 3: 4}" || table_str == ~"{3: 4, 1: 2}"); assert!(empty.to_str() == ~"{}"); } } \ No newline at end of file |
