1
Fork 0

DTSify libserialize traits

- ToBase64
- FromBase64
- ToHex
- FromHex
- ToJson
- Encodable
This commit is contained in:
Jorge Aparicio 2014-11-06 11:25:09 -05:00
parent 60a669a174
commit 679eb9191d
4 changed files with 25 additions and 18 deletions

View file

@ -2303,7 +2303,7 @@ impl ::Decoder<DecoderError> for Decoder {
}
/// A trait for converting values to JSON
pub trait ToJson {
pub trait ToJson for Sized? {
/// Converts the value of `self` to an instance of JSON
fn to_json(&self) -> Json;
}
@ -2389,7 +2389,7 @@ tuple_impl!{A, B, C, D, E, F, G, H, I, J}
tuple_impl!{A, B, C, D, E, F, G, H, I, J, K}
tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L}
impl<'a, A: ToJson> ToJson for &'a [A] {
impl<A: ToJson> ToJson for [A] {
fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
}