rollup merge of #18334 : csherratt/arc-encodable
This commit is contained in:
commit
40811f84ef
@ -17,6 +17,7 @@
|
||||
use std::path;
|
||||
use std::rc::Rc;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub trait Encoder<E> {
|
||||
// Primitive types:
|
||||
@ -556,6 +557,18 @@ fn decode(d: &mut D) -> Result<RefCell<T>, E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<E, S:Encoder<E>, T:Encodable<S, E>+Send+Sync> Encodable<S, E> for Arc<T> {
|
||||
fn encode(&self, s: &mut S) -> Result<(), E> {
|
||||
(**self).encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E, D:Decoder<E>,T:Decodable<D, E>+Send+Sync> Decodable<D, E> for Arc<T> {
|
||||
fn decode(d: &mut D) -> Result<Arc<T>, E> {
|
||||
Ok(Arc::new(try!(Decodable::decode(d))))
|
||||
}
|
||||
}
|
||||
|
||||
// ___________________________________________________________________________
|
||||
// Helper routines
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user