Skip to content

Commit 923a8f3

Browse files
committed
Implement ToJson for Vec<T>
Now that ~[T] is obsolete, we need to allow to_json() to work for vectors.
1 parent adcbf53 commit 923a8f3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libserialize/json.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,10 @@ impl<A:ToJson> ToJson for ~[A] {
22332233
fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
22342234
}
22352235

2236+
impl<A:ToJson> ToJson for Vec<A> {
2237+
fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
2238+
}
2239+
22362240
impl<A:ToJson> ToJson for TreeMap<~str, A> {
22372241
fn to_json(&self) -> Json {
22382242
let mut d = TreeMap::new();

0 commit comments

Comments
 (0)