diff --git a/src/libextra/serialize.rs b/src/libextra/serialize.rs index 8e75be651cfa6..9b0e00a41e508 100644 --- a/src/libextra/serialize.rs +++ b/src/libextra/serialize.rs @@ -20,6 +20,7 @@ Core encoding and decoding interfaces. use std::at_vec; use std::hashmap::{HashMap, HashSet}; +use std::rc::Rc; use std::trie::{TrieMap, TrieSet}; use std::vec; use ringbuf::RingBuf; @@ -405,6 +406,20 @@ impl> Encodable for @T { } } +impl + Freeze> Encodable for Rc { + #[inline] + fn encode(&self, s: &mut S) { + self.borrow().encode(s) + } +} + +impl + Freeze> Decodable for Rc { + #[inline] + fn decode(d: &mut D) -> Rc { + Rc::new(Decodable::decode(d)) + } +} + impl + 'static> Decodable for @T { fn decode(d: &mut D) -> @T { @Decodable::decode(d) diff --git a/src/libstd/to_bytes.rs b/src/libstd/to_bytes.rs index 8b424c53be0b8..28b79bdd320b4 100644 --- a/src/libstd/to_bytes.rs +++ b/src/libstd/to_bytes.rs @@ -18,6 +18,7 @@ use cast; use container::Container; use iter::Iterator; use option::{None, Option, Some}; +use rc::Rc; use str::{Str, StrSlice}; use vec::{Vector, ImmutableVector}; @@ -325,6 +326,13 @@ impl IterBytes for @mut A { } } +impl IterBytes for Rc { + #[inline] + fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { + self.borrow().iter_bytes(lsb0, f) + } +} + impl IterBytes for ~A { #[inline] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {