Update to rust HEAD

This commit is contained in:
Erick Tryzelaar 2015-02-10 07:50:43 -08:00
parent 4ca70c1396
commit 044825829a
3 changed files with 24 additions and 2 deletions

View File

@ -1468,6 +1468,19 @@ fn bench_manual_serialize_my_mem_writer1_escape(b: &mut Bencher) {
});
}
#[bench]
fn bench_decoder(b: &mut Bencher) {
use rustc_serialize::json::Json;
b.bytes = JSON_STR.len() as u64;
b.iter(|| {
let json = Json::from_str(JSON_STR).unwrap();
let mut decoder = rustc_serialize::json::Decoder::new(json);
let _log: Log = rustc_serialize::Decodable::decode(&mut decoder).unwrap();
});
}
#[bench]
fn bench_deserializer(b: &mut Bencher) {
b.bytes = JSON_STR.len() as u64;

View File

@ -39,6 +39,8 @@ pub enum ErrorCode {
impl fmt::Debug for ErrorCode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use std::fmt::Debug;
match *self {
//ErrorCode::ConversionError(ref token) => write!(f, "failed to convert {}", token),
ErrorCode::EOFWhileParsingList => "EOF While parsing list".fmt(f),
@ -91,7 +93,7 @@ impl error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::SyntaxError(..) => "syntax error",
Error::IoError(_) => "input/output error",
Error::IoError(ref error) => error.description().as_slice(),
/*
Error::ExpectedError(ref expected, _) => &expected,
Error::MissingFieldError(_) => "missing field",
@ -100,6 +102,13 @@ impl error::Error for Error {
}
}
fn cause(&self) -> Option<&error::Error> {
match *self {
Error::IoError(ref error) => Some(error),
_ => None,
}
}
}
impl fmt::Display for Error {

View File

@ -67,7 +67,7 @@ impl fmt::Debug for Value {
pub fn to_value<T>(value: &T) -> Value where T: ser::Serialize {
let mut writer = Writer::new();
writer.visit(value).unwrap();
writer.visit(value).ok().unwrap();
writer.unwrap()
}