@@ -74,10 +74,53 @@ impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) {
74
74
}
75
75
}
76
76
77
+ impl < A : ToStr > ToStr for & [ A ] {
78
+ #[ inline( always) ]
79
+ pure fn to_str( & self ) -> ~str {
80
+ unsafe {
81
+ // FIXME #4568
82
+ // Bleh -- not really unsafe
83
+ // push_str and push_char
84
+ let mut acc = ~"[ ", first = true;
85
+ for self.each |elt| {
86
+ unsafe {
87
+ if first { first = false; }
88
+ else { str::push_str(&mut acc, ~" , "); }
89
+ str::push_str(&mut acc, elt.to_str());
90
+ }
91
+ }
92
+ str::push_char(&mut acc, ']');
93
+ acc
94
+ }
95
+ }
96
+ }
97
+
77
98
impl<A:ToStr> ToStr for ~[A] {
78
99
#[inline(always)]
79
100
pure fn to_str(&self) -> ~str {
80
101
unsafe {
102
+ // FIXME #4568
103
+ // Bleh -- not really unsafe
104
+ // push_str and push_char
105
+ let mut acc = ~" [ ", first = true;
106
+ for self.each |elt| {
107
+ unsafe {
108
+ if first { first = false; }
109
+ else { str::push_str(&mut acc, ~" , "); }
110
+ str::push_str(&mut acc, elt.to_str());
111
+ }
112
+ }
113
+ str::push_char(&mut acc, ']');
114
+ acc
115
+ }
116
+ }
117
+ }
118
+
119
+ impl<A:ToStr> ToStr for @[A] {
120
+ #[inline(always)]
121
+ pure fn to_str(&self) -> ~str {
122
+ unsafe {
123
+ // FIXME #4568
81
124
// Bleh -- not really unsafe
82
125
// push_str and push_char
83
126
let mut acc = ~" [ ", first = true;
0 commit comments