mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 09:28:04 +00:00
Update for rustc 1.0.0-nightly (8903c21d6 2015-01-15 22:42:58 +0000)
This commit is contained in:
+7
-7
@@ -43,7 +43,7 @@ pub enum ErrorCode {
|
||||
impl fmt::Show for ErrorCode {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
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::EOFWhileParsingObject => "EOF While parsing object".fmt(f),
|
||||
ErrorCode::EOFWhileParsingString => "EOF While parsing string".fmt(f),
|
||||
@@ -60,7 +60,7 @@ impl fmt::Show for ErrorCode {
|
||||
ErrorCode::ExpectedObjectCommaOrEnd => "expected `,` or `}`".fmt(f),
|
||||
ErrorCode::ExpectedSomeIdent => "expected ident".fmt(f),
|
||||
ErrorCode::ExpectedSomeValue => "expected value".fmt(f),
|
||||
ErrorCode::ExpectedTokens(ref token, tokens) => write!(f, "expected {}, found {}", tokens, token),
|
||||
ErrorCode::ExpectedTokens(ref token, tokens) => write!(f, "expected {:?}, found {:?}", tokens, token),
|
||||
ErrorCode::InvalidEscape => "invalid escape".fmt(f),
|
||||
ErrorCode::InvalidNumber => "invalid number".fmt(f),
|
||||
ErrorCode::InvalidUnicodeCodePoint => "invalid unicode code point".fmt(f),
|
||||
@@ -71,7 +71,7 @@ impl fmt::Show for ErrorCode {
|
||||
ErrorCode::NotUtf8 => "contents not utf-8".fmt(f),
|
||||
ErrorCode::TrailingCharacters => "trailing characters".fmt(f),
|
||||
ErrorCode::UnexpectedEndOfHexEscape => "unexpected end of hex escape".fmt(f),
|
||||
ErrorCode::UnexpectedName(ref name) => write!(f, "unexpected name {}", name),
|
||||
ErrorCode::UnexpectedName(ref name) => write!(f, "unexpected name {:?}", name),
|
||||
ErrorCode::UnknownVariant => "unknown variant".fmt(f),
|
||||
ErrorCode::UnrecognizedHex => "invalid \\u escape (unrecognized hex)".fmt(f),
|
||||
}
|
||||
@@ -102,17 +102,17 @@ impl error::Error for Error {
|
||||
fn detail(&self) -> Option<String> {
|
||||
match *self {
|
||||
Error::SyntaxError(ref code, line, col) => {
|
||||
Some(format!("{} at line {} column {}", code, line, col))
|
||||
Some(format!("{:?} at line {:?} column {:?}", code, line, col))
|
||||
}
|
||||
Error::IoError(ref error) => error.detail(),
|
||||
Error::ExpectedError(ref expected, ref found) => {
|
||||
Some(format!("expected {}, found {}", expected, found))
|
||||
Some(format!("expected {:?}, found {:?}", expected, found))
|
||||
}
|
||||
Error::MissingFieldError(ref field) => {
|
||||
Some(format!("missing field {}", field))
|
||||
Some(format!("missing field {:?}", field))
|
||||
}
|
||||
Error::UnknownVariantError(ref variant) => {
|
||||
Some(format!("unknown variant {}", variant))
|
||||
Some(format!("unknown variant {:?}", variant))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -84,7 +84,7 @@ fn main() {
|
||||
let mut serializer = json::Serializer::new(wr.by_ref());
|
||||
match to_serialize_object.serialize(&mut serializer) {
|
||||
Ok(()) => (),
|
||||
Err(e) => panic!("json serialization error: {}", e),
|
||||
Err(e) => panic!("json serialization error: {:?}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ fn main() {
|
||||
let mut parser = json::Parser::new(json_str_to_deserialize.bytes());
|
||||
let deserialized_object: MyStruct = match Deserialize::deserialize(&mut parser) {
|
||||
Ok(v) => v,
|
||||
Err(e) => panic!("Decoding error: {}", e)
|
||||
Err(e) => panic!("Decoding error: {:?}", e)
|
||||
};
|
||||
}
|
||||
```
|
||||
@@ -234,7 +234,7 @@ fn main() {
|
||||
|
||||
let deserialized_object: TestStruct1 = match json::from_str(serialized_str.as_slice()) {
|
||||
Ok(deserialized_object) => deserialized_object,
|
||||
Err(e) => panic!("json deserialization error: {}", e),
|
||||
Err(e) => panic!("json deserialization error: {:?}", e),
|
||||
};
|
||||
}
|
||||
```
|
||||
@@ -1918,7 +1918,7 @@ mod bench {
|
||||
match parser.next() {
|
||||
None => return,
|
||||
Some(Ok(_)) => { }
|
||||
Some(Err(err)) => { panic!("error: {}", err); }
|
||||
Some(Err(err)) => { panic!("error: {:?}", err); }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+12
-3
@@ -3,6 +3,7 @@ use std::fmt;
|
||||
use std::io::{ByRefWriter, IoResult};
|
||||
use std::io;
|
||||
use std::str;
|
||||
use std::string::ToString;
|
||||
use std::vec;
|
||||
|
||||
use de::{self, Token, TokenKind};
|
||||
@@ -207,6 +208,14 @@ impl Value {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for Value {
|
||||
fn to_string(&self) -> String {
|
||||
let mut wr = Vec::new();
|
||||
self.to_writer(wr.by_ref()).unwrap();
|
||||
str::from_utf8(wr.as_slice()).unwrap().to_string()
|
||||
}
|
||||
}
|
||||
|
||||
struct WriterFormatter<'a, 'b: 'a> {
|
||||
inner: &'a mut fmt::Formatter<'b>,
|
||||
}
|
||||
@@ -449,7 +458,7 @@ impl de::Deserializer<Error> for Deserializer {
|
||||
return Err(
|
||||
Error::ExpectedError(
|
||||
"Array".to_string(),
|
||||
format!("{} => {}", key, value)
|
||||
format!("{:?} => {:?}", key, value)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -464,7 +473,7 @@ impl de::Deserializer<Error> for Deserializer {
|
||||
return Err(
|
||||
Error::ExpectedError(
|
||||
"None".to_string(),
|
||||
format!("{} => {}", key, value)
|
||||
format!("{:?} => {:?}", key, value)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -483,7 +492,7 @@ impl de::Deserializer<Error> for Deserializer {
|
||||
return Err(
|
||||
Error::ExpectedError(
|
||||
"String or Object".to_string(),
|
||||
format!("{}", token)
|
||||
format!("{:?}", token)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user