Restore Decodable impl for ~[T]
Bring back the Decodable impl for ~[T], this time using FromVec. It's still not recommended that anyone use this, but at least it's available if necessary.
This commit is contained in:
parent
9fb8741b2e
commit
f582150159
@ -451,6 +451,21 @@ impl<E, S:Encoder<E>,T:Encodable<S, E>> Encodable<S, E> for ~[T] {
|
||||
}
|
||||
}
|
||||
|
||||
impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for ~[T] {
|
||||
fn decode(d: &mut D) -> Result<~[T], E> {
|
||||
use std::vec::FromVec;
|
||||
|
||||
d.read_seq(|d, len| {
|
||||
let mut v: Vec<T> = Vec::with_capacity(len);
|
||||
for i in range(0, len) {
|
||||
v.push(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
|
||||
}
|
||||
let k: ~[T] = FromVec::from_vec(v);
|
||||
Ok(k)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<E, S:Encoder<E>,T:Encodable<S, E>> Encodable<S, E> for Vec<T> {
|
||||
fn encode(&self, s: &mut S) -> Result<(), E> {
|
||||
s.emit_seq(self.len(), |s| {
|
||||
|
Loading…
Reference in New Issue
Block a user