Skip to content

Commit 71f26d5

Browse files
stepanchegthestinger
authored andcommitted
---
yaml --- r: 69320 b: refs/heads/auto c: c50d3e3 h: refs/heads/master v: v3
1 parent f65997e commit 71f26d5

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 8d3bb7eb306993430e5f5acf3e3fbf22d7a9d97f
17+
refs/heads/auto: c50d3e3fca5760fff19f6c8304c608d2b41eba45
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libstd/to_str.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<A:ToStr> ToStr for (A,) {
5050
}
5151
}
5252

53-
impl<A:ToStr+Hash+Eq, B:ToStr+Hash+Eq> ToStr for HashMap<A, B> {
53+
impl<A:ToStr+Hash+Eq, B:ToStr> ToStr for HashMap<A, B> {
5454
#[inline]
5555
fn to_str(&self) -> ~str {
5656
let mut acc = ~"{";
@@ -182,6 +182,8 @@ mod tests {
182182
use hashmap::HashMap;
183183
use hashmap::HashSet;
184184
use container::{MutableSet, MutableMap};
185+
use super::*;
186+
185187
#[test]
186188
fn test_simple_types() {
187189
assert_eq!(1i.to_str(), ~"1");
@@ -212,17 +214,27 @@ mod tests {
212214
~"[[], [1], [1, 1]]");
213215
}
214216
217+
struct StructWithToStrWithoutEqOrHash {
218+
value: int
219+
}
220+
221+
impl ToStr for StructWithToStrWithoutEqOrHash {
222+
fn to_str(&self) -> ~str {
223+
fmt!("s%d", self.value)
224+
}
225+
}
226+
215227
#[test]
216228
fn test_hashmap() {
217-
let mut table: HashMap<int, int> = HashMap::new();
218-
let empty: HashMap<int, int> = HashMap::new();
229+
let mut table: HashMap<int, StructWithToStrWithoutEqOrHash> = HashMap::new();
230+
let empty: HashMap<int, StructWithToStrWithoutEqOrHash> = HashMap::new();
219231
220-
table.insert(3, 4);
221-
table.insert(1, 2);
232+
table.insert(3, StructWithToStrWithoutEqOrHash { value: 4 });
233+
table.insert(1, StructWithToStrWithoutEqOrHash { value: 2 });
222234
223235
let table_str = table.to_str();
224236
225-
assert!(table_str == ~"{1: 2, 3: 4}" || table_str == ~"{3: 4, 1: 2}");
237+
assert!(table_str == ~"{1: s2, 3: s4}" || table_str == ~"{3: s4, 1: s2}");
226238
assert_eq!(empty.to_str(), ~"{}");
227239
}
228240

0 commit comments

Comments
 (0)