Skip to content

Commit e4aa6fd

Browse files
stepanchegthestinger
authored andcommitted
---
yaml --- r: 64693 b: refs/heads/snap-stage3 c: c50d3e3 h: refs/heads/master i: 64691: 78a6edc v: v3
1 parent e9f3533 commit e4aa6fd

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 8d3bb7eb306993430e5f5acf3e3fbf22d7a9d97f
4+
refs/heads/snap-stage3: c50d3e3fca5760fff19f6c8304c608d2b41eba45
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)