mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 01:05:39 +03:00
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.
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
|
||||
use str;
|
||||
use str::OwnedStr;
|
||||
use hashmap::HashMap;
|
||||
use hashmap::HashSet;
|
||||
use container::Map;
|
||||
use hash::Hash;
|
||||
use cmp::Eq;
|
||||
@@ -59,13 +61,13 @@ fn to_str(&self) -> ~str {
|
||||
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 @@ fn to_str(&self) -> ~str {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) {
|
||||
#[inline(always)]
|
||||
fn to_str(&self) -> ~str {
|
||||
@@ -185,7 +188,7 @@ fn test_hashmap() {
|
||||
|
||||
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() == ~"{}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user