Skip to content

Instantly share code, notes, and snippets.

@jordansissel
Last active August 29, 2015 14:24
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 jordansissel/b5d3fd3524654d1d9be2 to your computer and use it in GitHub Desktop.
Save jordansissel/b5d3fd3524654d1d9be2 to your computer and use it in GitHub Desktop.
use rustc_serialize::json::{Json,Decoder};
use rustc_serialize::Decodable;
use std::io::Read;
pub fn parse<T: Read, R: Decodable, E>(mut r: T) -> Result<R, E> {
let item = try!(Json::from_reader(&mut r));
let mut decoder = Decoder::new(item);
let result: R = try!(Decodable::decode(&mut decoder));
Ok(result)
}
<std macros>:6:1: 6:32 error: the trait `core::convert::From<rustc_serialize::json::ParserError>` is not implemented for the type `E` [E0277]
<std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:48 note: in expansion of try!
src/github/body.rs:6:14: 6:45 note: expansion site
<std macros>:6:1: 6:32 error: the trait `core::convert::From<rustc_serialize::json::DecoderError>` is not implemented for the type `E` [E0277]
<std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:48 note: in expansion of try!
src/github/body.rs:9:19: 9:56 note: expansion site
error: aborting due to 2 previous errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment