mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 11:21:01 +00:00
Merge pull request #16 from tomprogrammer/rust-head
Follow changes in std / rustc
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#![feature(plugin_registrar, quote)]
|
#![feature(plugin_registrar, quote, unboxed_closures)]
|
||||||
|
|
||||||
extern crate syntax;
|
extern crate syntax;
|
||||||
extern crate rustc;
|
extern crate rustc;
|
||||||
@@ -62,8 +62,7 @@ fn expand_deriving_serialize<>(cx: &mut ExtCtxt,
|
|||||||
sp: Span,
|
sp: Span,
|
||||||
mitem: &MetaItem,
|
mitem: &MetaItem,
|
||||||
item: &Item,
|
item: &Item,
|
||||||
push: |P<ast::Item>|) //where
|
mut push: Box<FnMut(P<ast::Item>)>)
|
||||||
//F: FnOnce(P<ast::Item>)
|
|
||||||
{
|
{
|
||||||
let inline = cx.meta_word(sp, token::InternedString::new("inline"));
|
let inline = cx.meta_word(sp, token::InternedString::new("inline"));
|
||||||
let attrs = vec!(cx.attribute(sp, inline));
|
let attrs = vec!(cx.attribute(sp, inline));
|
||||||
@@ -80,12 +79,11 @@ fn expand_deriving_serialize<>(cx: &mut ExtCtxt,
|
|||||||
generics: LifetimeBounds {
|
generics: LifetimeBounds {
|
||||||
lifetimes: Vec::new(),
|
lifetimes: Vec::new(),
|
||||||
bounds: vec![
|
bounds: vec![
|
||||||
("__S", None, vec![]),
|
("__S", vec![]),
|
||||||
("__R", None, vec![]),
|
("__R", vec![]),
|
||||||
("__E", None, vec![]),
|
("__E", vec![]),
|
||||||
(
|
(
|
||||||
"__V",
|
"__V",
|
||||||
None,
|
|
||||||
vec![
|
vec![
|
||||||
Path::new_(
|
Path::new_(
|
||||||
vec!["serde2", "ser", "Visitor"],
|
vec!["serde2", "ser", "Visitor"],
|
||||||
@@ -130,7 +128,7 @@ fn expand_deriving_serialize<>(cx: &mut ExtCtxt,
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
trait_def.expand(cx, mitem, item, |item| push(item))
|
trait_def.expand(cx, mitem, item, |item| push.call_mut((item,)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
|
fn serialize_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::f64;
|
use std::f64;
|
||||||
use std::io::{mod, ByRefWriter, IoError};
|
use std::io::{mod, ByRefWriter, IoError};
|
||||||
use std::num::{Float, FPNaN, FPInfinite};
|
use std::num::{Float, FpCategory};
|
||||||
use std::str::Utf8Error;
|
use std::string::FromUtf8Error;
|
||||||
|
|
||||||
use ser;
|
use ser;
|
||||||
use ser::Serializer;
|
use ser::Serializer;
|
||||||
@@ -225,7 +225,7 @@ pub fn escape_char<W: io::Writer>(wr: &mut W, value: char) -> Result<(), IoError
|
|||||||
|
|
||||||
fn fmt_f64_or_null<W: io::Writer>(wr: &mut W, value: f64) -> Result<(), IoError> {
|
fn fmt_f64_or_null<W: io::Writer>(wr: &mut W, value: f64) -> Result<(), IoError> {
|
||||||
match value.classify() {
|
match value.classify() {
|
||||||
FPNaN | FPInfinite => wr.write_str("null"),
|
FpCategory::Nan | FpCategory::Infinite => wr.write_str("null"),
|
||||||
_ => wr.write_str(f64::to_str_digits(value, 6).as_slice()),
|
_ => wr.write_str(f64::to_str_digits(value, 6).as_slice()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,7 +252,7 @@ pub fn to_vec<
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_string<
|
pub fn to_string<
|
||||||
T: ser::Serialize,
|
T: ser::Serialize,
|
||||||
>(value: &T) -> Result<Result<String, (Vec<u8>, Utf8Error)>, IoError> {
|
>(value: &T) -> Result<Result<String, FromUtf8Error>, IoError> {
|
||||||
let vec = try!(to_vec(value));
|
let vec = try!(to_vec(value));
|
||||||
Ok(String::from_utf8(vec))
|
Ok(String::from_utf8(vec))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#![crate_name = "serde_macros"]
|
#![crate_name = "serde_macros"]
|
||||||
#![crate_type = "dylib"]
|
#![crate_type = "dylib"]
|
||||||
|
|
||||||
#![feature(plugin_registrar, quote)]
|
#![feature(plugin_registrar, quote, unboxed_closures)]
|
||||||
|
|
||||||
extern crate syntax;
|
extern crate syntax;
|
||||||
extern crate rustc;
|
extern crate rustc;
|
||||||
@@ -70,7 +70,7 @@ fn expand_deriving_serialize(cx: &mut ExtCtxt,
|
|||||||
sp: Span,
|
sp: Span,
|
||||||
mitem: &MetaItem,
|
mitem: &MetaItem,
|
||||||
item: &Item,
|
item: &Item,
|
||||||
push: |P<ast::Item>|) {
|
mut push: Box<FnMut(P<ast::Item>)>) {
|
||||||
let inline = cx.meta_word(sp, token::InternedString::new("inline"));
|
let inline = cx.meta_word(sp, token::InternedString::new("inline"));
|
||||||
let attrs = vec!(cx.attribute(sp, inline));
|
let attrs = vec!(cx.attribute(sp, inline));
|
||||||
|
|
||||||
@@ -83,10 +83,10 @@ fn expand_deriving_serialize(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: LifetimeBounds {
|
generics: LifetimeBounds {
|
||||||
lifetimes: Vec::new(),
|
lifetimes: Vec::new(),
|
||||||
bounds: vec!(("__S", None, vec!(Path::new_(
|
bounds: vec!(("__S", vec!(Path::new_(
|
||||||
vec!("serde", "ser", "Serializer"), None,
|
vec!("serde", "ser", "Serializer"), None,
|
||||||
vec!(box Literal(Path::new_local("__E"))), true))),
|
vec!(box Literal(Path::new_local("__E"))), true))),
|
||||||
("__E", None, vec!()))
|
("__E", vec!()))
|
||||||
},
|
},
|
||||||
methods: vec!(
|
methods: vec!(
|
||||||
MethodDef {
|
MethodDef {
|
||||||
@@ -113,7 +113,7 @@ fn expand_deriving_serialize(cx: &mut ExtCtxt,
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
trait_def.expand(cx, mitem, item, |item| push(item))
|
trait_def.expand(cx, mitem, item, |item| push.call_mut((item,)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_substructure(cx: &ExtCtxt,
|
fn serialize_substructure(cx: &ExtCtxt,
|
||||||
@@ -199,7 +199,7 @@ pub fn expand_deriving_deserialize(cx: &mut ExtCtxt,
|
|||||||
span: Span,
|
span: Span,
|
||||||
mitem: &MetaItem,
|
mitem: &MetaItem,
|
||||||
item: &Item,
|
item: &Item,
|
||||||
push: |P<Item>|) {
|
mut push: Box<FnMut(P<Item>)>) {
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span: span,
|
span: span,
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
@@ -209,10 +209,10 @@ pub fn expand_deriving_deserialize(cx: &mut ExtCtxt,
|
|||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: LifetimeBounds {
|
generics: LifetimeBounds {
|
||||||
lifetimes: Vec::new(),
|
lifetimes: Vec::new(),
|
||||||
bounds: vec!(("__D", None, vec!(Path::new_(
|
bounds: vec!(("__D", vec!(Path::new_(
|
||||||
vec!("serde", "de", "Deserializer"), None,
|
vec!("serde", "de", "Deserializer"), None,
|
||||||
vec!(box Literal(Path::new_local("__E"))), true))),
|
vec!(box Literal(Path::new_local("__E"))), true))),
|
||||||
("__E", None, vec!()))
|
("__E", vec!()))
|
||||||
},
|
},
|
||||||
methods: vec!(
|
methods: vec!(
|
||||||
MethodDef {
|
MethodDef {
|
||||||
@@ -244,7 +244,7 @@ pub fn expand_deriving_deserialize(cx: &mut ExtCtxt,
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
trait_def.expand(cx, mitem, item, |item| push(item))
|
trait_def.expand(cx, mitem, item, |item| push.call_mut((item,)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_substructure(cx: &mut ExtCtxt,
|
fn deserialize_substructure(cx: &mut ExtCtxt,
|
||||||
|
|||||||
+6
-6
@@ -1,8 +1,8 @@
|
|||||||
use std::f32;
|
use std::f32;
|
||||||
use std::f64;
|
use std::f64;
|
||||||
use std::num::{Float, FPNaN, FPInfinite};
|
use std::num::{Float, FpCategory};
|
||||||
use std::io::{IoError, IoResult};
|
use std::io::{IoError, IoResult};
|
||||||
use std::str::Utf8Error;
|
use std::string::FromUtf8Error;
|
||||||
|
|
||||||
use ser::Serialize;
|
use ser::Serialize;
|
||||||
use ser;
|
use ser;
|
||||||
@@ -52,14 +52,14 @@ fn escape_char<W: Writer>(wr: &mut W, v: char) -> IoResult<()> {
|
|||||||
|
|
||||||
fn fmt_f32_or_null<W: Writer>(wr: &mut W, v: f32) -> IoResult<()> {
|
fn fmt_f32_or_null<W: Writer>(wr: &mut W, v: f32) -> IoResult<()> {
|
||||||
match v.classify() {
|
match v.classify() {
|
||||||
FPNaN | FPInfinite => wr.write_str("null"),
|
FpCategory::Nan | FpCategory::Infinite => wr.write_str("null"),
|
||||||
_ => wr.write_str(f32::to_str_digits(v, 6).as_slice()),
|
_ => wr.write_str(f32::to_str_digits(v, 6).as_slice()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_f64_or_null<W: Writer>(wr: &mut W, v: f64) -> IoResult<()> {
|
fn fmt_f64_or_null<W: Writer>(wr: &mut W, v: f64) -> IoResult<()> {
|
||||||
match v.classify() {
|
match v.classify() {
|
||||||
FPNaN | FPInfinite => wr.write_str("null"),
|
FpCategory::Nan | FpCategory::Infinite => wr.write_str("null"),
|
||||||
_ => wr.write_str(f64::to_str_digits(v, 6).as_slice()),
|
_ => wr.write_str(f64::to_str_digits(v, 6).as_slice()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -600,7 +600,7 @@ pub fn to_vec<
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_string<
|
pub fn to_string<
|
||||||
T: Serialize<Serializer<Vec<u8>>, IoError>
|
T: Serialize<Serializer<Vec<u8>>, IoError>
|
||||||
>(value: &T) -> Result<String, (Vec<u8>, Utf8Error)> {
|
>(value: &T) -> Result<String, FromUtf8Error> {
|
||||||
let buf = to_vec(value);
|
let buf = to_vec(value);
|
||||||
String::from_utf8(buf)
|
String::from_utf8(buf)
|
||||||
}
|
}
|
||||||
@@ -629,7 +629,7 @@ pub fn to_pretty_vec<
|
|||||||
/// Encode the specified struct into a json `String` buffer.
|
/// Encode the specified struct into a json `String` buffer.
|
||||||
pub fn to_pretty_string<
|
pub fn to_pretty_string<
|
||||||
T: Serialize<PrettySerializer<Vec<u8>>, IoError>
|
T: Serialize<PrettySerializer<Vec<u8>>, IoError>
|
||||||
>(value: &T) -> Result<String, (Vec<u8>, Utf8Error)> {
|
>(value: &T) -> Result<String, FromUtf8Error> {
|
||||||
let buf = to_pretty_vec(value);
|
let buf = to_pretty_vec(value);
|
||||||
String::from_utf8(buf)
|
String::from_utf8(buf)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user