mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 18:21:01 +00:00
Update to rust HEAD
This commit is contained in:
@@ -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]
|
#[bench]
|
||||||
fn bench_deserializer(b: &mut Bencher) {
|
fn bench_deserializer(b: &mut Bencher) {
|
||||||
b.bytes = JSON_STR.len() as u64;
|
b.bytes = JSON_STR.len() as u64;
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ pub enum ErrorCode {
|
|||||||
|
|
||||||
impl fmt::Debug for ErrorCode {
|
impl fmt::Debug for ErrorCode {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
use std::fmt::Debug;
|
||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
//ErrorCode::ConversionError(ref token) => write!(f, "failed to convert {}", token),
|
//ErrorCode::ConversionError(ref token) => write!(f, "failed to convert {}", token),
|
||||||
ErrorCode::EOFWhileParsingList => "EOF While parsing list".fmt(f),
|
ErrorCode::EOFWhileParsingList => "EOF While parsing list".fmt(f),
|
||||||
@@ -91,7 +93,7 @@ impl error::Error for Error {
|
|||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
Error::SyntaxError(..) => "syntax error",
|
Error::SyntaxError(..) => "syntax error",
|
||||||
Error::IoError(_) => "input/output error",
|
Error::IoError(ref error) => error.description().as_slice(),
|
||||||
/*
|
/*
|
||||||
Error::ExpectedError(ref expected, _) => &expected,
|
Error::ExpectedError(ref expected, _) => &expected,
|
||||||
Error::MissingFieldError(_) => "missing field",
|
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 {
|
impl fmt::Display for Error {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ impl fmt::Debug for Value {
|
|||||||
|
|
||||||
pub fn to_value<T>(value: &T) -> Value where T: ser::Serialize {
|
pub fn to_value<T>(value: &T) -> Value where T: ser::Serialize {
|
||||||
let mut writer = Writer::new();
|
let mut writer = Writer::new();
|
||||||
writer.visit(value).unwrap();
|
writer.visit(value).ok().unwrap();
|
||||||
writer.unwrap()
|
writer.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user