Skip to content

Instantly share code, notes, and snippets.

@apoelstra
Created July 8, 2014 16:44
Show Gist options
  • Save apoelstra/d1e7ca6eaf70ce5f4ce6 to your computer and use it in GitHub Desktop.
Save apoelstra/d1e7ca6eaf70ce5f4ce6 to your computer and use it in GitHub Desktop.
borrow of RefCell
impl <T:Serializable> Serializable for RefCell<T> {
fn serialize(&self) -> Vec<u8> {
self.borrow().serialize()
}
fn serialize_iter<'a>(&'a self) -> SerializeIter<'a> {
self.borrow().serialize_iter()
}
fn deserialize<I: Iterator<u8>>(iter: I) -> IoResult<RefCell<T>> {
let ret: T = try!(Serializable::deserialize(iter));
Ok(RefCell::new(ret))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment