Skip to content

Instantly share code, notes, and snippets.

@pzol
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pzol/786bf97c960d71c45b85 to your computer and use it in GitHub Desktop.
Save pzol/786bf97c960d71c45b85 to your computer and use it in GitHub Desktop.
use std::io::{self, IoResult, MemReader};
use rustc_serialize::{ Encodable };
use rustc_serialize::json::{ self, Json };
use response::IntoReader;
pub trait IntoReader {
type OutReader: Reader;
fn into_reader(self) -> Self::OutReader;
}
impl IntoReader for Json {
type OutReader = MemReader;
fn into_reader<T: Encodable>(self) -> MemReader {
MemReader::new(json::encode(&self).into_bytes())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment